├── Deployment ├── Examples │ ├── simple_test_k64f_gcc │ │ ├── CMSIS_5 │ │ ├── Source │ │ ├── simple_test │ │ ├── mbed.bld │ │ ├── mbed │ │ │ ├── .bld │ │ │ │ └── bldrc │ │ │ ├── TARGET_K64F │ │ │ │ ├── TOOLCHAIN_GCC_ARM │ │ │ │ │ └── libmbed.a │ │ │ │ ├── TARGET_Freescale │ │ │ │ │ ├── TARGET_MCUXpresso_MCUS │ │ │ │ │ │ ├── TARGET_MCU_K64F │ │ │ │ │ │ │ ├── device │ │ │ │ │ │ │ │ ├── cmsis.h │ │ │ │ │ │ │ │ ├── cmsis_nvic.h │ │ │ │ │ │ │ │ └── fsl_device_registers.h │ │ │ │ │ │ │ ├── TARGET_FRDM │ │ │ │ │ │ │ │ ├── device.h │ │ │ │ │ │ │ │ ├── crc.h │ │ │ │ │ │ │ │ └── fsl_clock_config.h │ │ │ │ │ │ │ ├── peripheral_clock_defines.h │ │ │ │ │ │ │ └── dma_reqs.h │ │ │ │ │ │ └── api │ │ │ │ │ │ │ ├── PortNames.h │ │ │ │ │ │ │ ├── gpio_object.h │ │ │ │ │ │ │ ├── PeripheralPins.h │ │ │ │ │ │ │ ├── dma_api_hal.h │ │ │ │ │ │ │ └── objects.h │ │ │ │ │ └── mbed_rtx.h │ │ │ │ ├── mbed_lib.json │ │ │ │ ├── cmsis_version.h │ │ │ │ └── tz_context.h │ │ │ ├── platform │ │ │ │ ├── mbed_sleep.h │ │ │ │ ├── sleep.h │ │ │ │ ├── critical.h │ │ │ │ ├── rtc_time.h │ │ │ │ ├── wait_api.h │ │ │ │ ├── semihost_api.h │ │ │ │ ├── toolchain.h │ │ │ │ ├── platform.h │ │ │ │ ├── PlatformMutex.h │ │ │ │ ├── FileLike.h │ │ │ │ ├── FilePath.h │ │ │ │ ├── mbed_application.h │ │ │ │ ├── mbed_wait_api.h │ │ │ │ ├── FileBase.h │ │ │ │ ├── mbed_poll.h │ │ │ │ ├── mbed_debug.h │ │ │ │ ├── Transaction.h │ │ │ │ ├── mbed_error.h │ │ │ │ ├── ScopedLock.h │ │ │ │ ├── mbed_preprocessor.h │ │ │ │ ├── DeepSleepLock.h │ │ │ │ ├── Stream.h │ │ │ │ ├── mbed_semihost_api.h │ │ │ │ ├── mbed_rtc_time.h │ │ │ │ ├── mbed_stats.h │ │ │ │ ├── FileSystemLike.h │ │ │ │ ├── FunctionPointer.h │ │ │ │ └── SingletonPtr.h │ │ │ ├── hal │ │ │ │ ├── buffer.h │ │ │ │ ├── dma_api.h │ │ │ │ ├── pinmap.h │ │ │ │ ├── rtc_api.h │ │ │ │ ├── trng_api.h │ │ │ │ ├── ethernet_api.h │ │ │ │ ├── can_helper.h │ │ │ │ ├── analogin_api.h │ │ │ │ ├── Driver_Common.h │ │ │ │ ├── itm_api.h │ │ │ │ ├── sleep_api.h │ │ │ │ ├── can_api.h │ │ │ │ ├── port_api.h │ │ │ │ ├── gpio_irq_api.h │ │ │ │ ├── analogout_api.h │ │ │ │ ├── us_ticker_api.h │ │ │ │ ├── lp_ticker_api.h │ │ │ │ └── flash_data.h │ │ │ └── drivers │ │ │ │ ├── TableCRC.h │ │ │ │ ├── LowPowerTimer.h │ │ │ │ ├── LowPowerTimeout.h │ │ │ │ ├── LowPowerTicker.h │ │ │ │ ├── Timeout.h │ │ │ │ ├── SerialWireOutput.h │ │ │ │ ├── TimerEvent.h │ │ │ │ ├── PortIn.h │ │ │ │ ├── Timer.h │ │ │ │ ├── RawSerial.h │ │ │ │ ├── PortOut.h │ │ │ │ ├── DigitalIn.h │ │ │ │ ├── PortInOut.h │ │ │ │ └── AnalogIn.h │ │ └── mbed_config.h │ ├── realtime_test │ │ ├── mbed_libs │ │ │ ├── mbed.lib │ │ │ ├── BSP_DISCO_F746NG.lib │ │ │ ├── LCD_DISCO_F746NG.lib │ │ │ └── AUDIO_DISCO_F746NG.lib │ │ └── plot_utils.h │ └── simple_test │ │ └── main.cpp ├── release_O3.json └── Source │ ├── KWS │ ├── KWS_DNN │ │ ├── kws_dnn.h │ │ └── kws_dnn.cpp │ ├── KWS_DS_CNN │ │ ├── kws_ds_cnn.h │ │ └── kws_ds_cnn.cpp │ ├── kws.h │ └── kws.cpp │ ├── NN │ ├── nn.cpp │ ├── nn.h │ └── DNN │ │ ├── dnn.h │ │ └── dnn.cpp │ ├── KWS_F746NG │ ├── kws_f746ng.h │ └── kws_f746ng.cpp │ ├── local_NN │ ├── local_NN.h │ └── arm_avepool_q7_HWC_nonsquare.c │ └── MFCC │ └── mfcc.h ├── silence.wav ├── audio ├── six_clip_000f49605.wav ├── go_00f0204f_nohash_0.wav ├── off_0bd689d7_nohash_0.wav ├── on_1b4c9b89_nohash_2.wav ├── stop_clip_00a4675b5.wav ├── five_00f0204f_nohash_0.wav └── stop_0bd689d7_nohash_2.wav ├── Pretrained_models ├── CNN │ ├── CNN_L.pb │ ├── CNN_M.pb │ └── CNN_S.pb ├── DNN │ ├── DNN_L.pb │ ├── DNN_M.pb │ └── DNN_S.pb ├── GRU │ ├── GRU_L.pb │ ├── GRU_M.pb │ └── GRU_S.pb ├── CRNN │ ├── CRNN_L.pb │ ├── CRNN_M.pb │ └── CRNN_S.pb ├── LSTM │ ├── LSTM_L.pb │ ├── LSTM_M.pb │ └── LSTM_S.pb ├── DS_CNN │ ├── DS_CNN_L.pb │ ├── DS_CNN_M.pb │ └── DS_CNN_S.pb ├── labels.txt └── Basic_LSTM │ ├── Basic_LSTM_L.pb │ ├── Basic_LSTM_M.pb │ └── Basic_LSTM_S.pb ├── .gitignore └── MCU-KWS-explore.ipynb /Deployment/Examples/simple_test_k64f_gcc/CMSIS_5: -------------------------------------------------------------------------------- 1 | ../../CMSIS_5 -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/Source: -------------------------------------------------------------------------------- 1 | ../../Source -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/simple_test: -------------------------------------------------------------------------------- 1 | ../simple_test -------------------------------------------------------------------------------- /silence.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/silence.wav -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed.bld: -------------------------------------------------------------------------------- 1 | http://mbed.org/users/mbed_official/code/mbed/builds/5aab5a7997ee -------------------------------------------------------------------------------- /audio/six_clip_000f49605.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/audio/six_clip_000f49605.wav -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/.bld/bldrc: -------------------------------------------------------------------------------- 1 | http://mbed.org/users/mbed_official/code/mbed/builds/5aab5a7997ee -------------------------------------------------------------------------------- /Pretrained_models/CNN/CNN_L.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/CNN/CNN_L.pb -------------------------------------------------------------------------------- /Pretrained_models/CNN/CNN_M.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/CNN/CNN_M.pb -------------------------------------------------------------------------------- /Pretrained_models/CNN/CNN_S.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/CNN/CNN_S.pb -------------------------------------------------------------------------------- /Pretrained_models/DNN/DNN_L.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/DNN/DNN_L.pb -------------------------------------------------------------------------------- /Pretrained_models/DNN/DNN_M.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/DNN/DNN_M.pb -------------------------------------------------------------------------------- /Pretrained_models/DNN/DNN_S.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/DNN/DNN_S.pb -------------------------------------------------------------------------------- /Pretrained_models/GRU/GRU_L.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/GRU/GRU_L.pb -------------------------------------------------------------------------------- /Pretrained_models/GRU/GRU_M.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/GRU/GRU_M.pb -------------------------------------------------------------------------------- /Pretrained_models/GRU/GRU_S.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/GRU/GRU_S.pb -------------------------------------------------------------------------------- /audio/go_00f0204f_nohash_0.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/audio/go_00f0204f_nohash_0.wav -------------------------------------------------------------------------------- /audio/off_0bd689d7_nohash_0.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/audio/off_0bd689d7_nohash_0.wav -------------------------------------------------------------------------------- /audio/on_1b4c9b89_nohash_2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/audio/on_1b4c9b89_nohash_2.wav -------------------------------------------------------------------------------- /audio/stop_clip_00a4675b5.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/audio/stop_clip_00a4675b5.wav -------------------------------------------------------------------------------- /Deployment/Examples/realtime_test/mbed_libs/mbed.lib: -------------------------------------------------------------------------------- 1 | https://mbed.org/users/mbed_official/code/mbed/builds/#7130f322cb7e 2 | -------------------------------------------------------------------------------- /Pretrained_models/CRNN/CRNN_L.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/CRNN/CRNN_L.pb -------------------------------------------------------------------------------- /Pretrained_models/CRNN/CRNN_M.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/CRNN/CRNN_M.pb -------------------------------------------------------------------------------- /Pretrained_models/CRNN/CRNN_S.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/CRNN/CRNN_S.pb -------------------------------------------------------------------------------- /Pretrained_models/LSTM/LSTM_L.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/LSTM/LSTM_L.pb -------------------------------------------------------------------------------- /Pretrained_models/LSTM/LSTM_M.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/LSTM/LSTM_M.pb -------------------------------------------------------------------------------- /Pretrained_models/LSTM/LSTM_S.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/LSTM/LSTM_S.pb -------------------------------------------------------------------------------- /audio/five_00f0204f_nohash_0.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/audio/five_00f0204f_nohash_0.wav -------------------------------------------------------------------------------- /audio/stop_0bd689d7_nohash_2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/audio/stop_0bd689d7_nohash_2.wav -------------------------------------------------------------------------------- /Pretrained_models/DS_CNN/DS_CNN_L.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/DS_CNN/DS_CNN_L.pb -------------------------------------------------------------------------------- /Pretrained_models/DS_CNN/DS_CNN_M.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/DS_CNN/DS_CNN_M.pb -------------------------------------------------------------------------------- /Pretrained_models/DS_CNN/DS_CNN_S.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/DS_CNN/DS_CNN_S.pb -------------------------------------------------------------------------------- /Deployment/Examples/realtime_test/mbed_libs/BSP_DISCO_F746NG.lib: -------------------------------------------------------------------------------- 1 | https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#56384bddaba5 2 | -------------------------------------------------------------------------------- /Deployment/Examples/realtime_test/mbed_libs/LCD_DISCO_F746NG.lib: -------------------------------------------------------------------------------- 1 | https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98 2 | -------------------------------------------------------------------------------- /Deployment/Examples/realtime_test/mbed_libs/AUDIO_DISCO_F746NG.lib: -------------------------------------------------------------------------------- 1 | https://developer.mbed.org/teams/ST/code/AUDIO_DISCO_F746NG/#7046ce26b7ed 2 | -------------------------------------------------------------------------------- /Pretrained_models/labels.txt: -------------------------------------------------------------------------------- 1 | _silence_ 2 | _unknown_ 3 | yes 4 | no 5 | up 6 | down 7 | left 8 | right 9 | on 10 | off 11 | stop 12 | go -------------------------------------------------------------------------------- /Pretrained_models/Basic_LSTM/Basic_LSTM_L.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/Basic_LSTM/Basic_LSTM_L.pb -------------------------------------------------------------------------------- /Pretrained_models/Basic_LSTM/Basic_LSTM_M.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/Basic_LSTM/Basic_LSTM_M.pb -------------------------------------------------------------------------------- /Pretrained_models/Basic_LSTM/Basic_LSTM_S.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Pretrained_models/Basic_LSTM/Basic_LSTM_S.pb -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/libmbed.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tony607/Keyword-detection/HEAD/Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/libmbed.a -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # python related 2 | *.pyc 3 | 4 | # C/C++ related 5 | *.o 6 | *.d 7 | *.elf 8 | *.bin 9 | *.map 10 | 11 | # Temp files 12 | *.swp 13 | *.swo 14 | 15 | *.ipynb_checkpoints 16 | __pycache__ 17 | .vscode 18 | logs/ -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/cmsis.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library - CMSIS 2 | * Copyright (C) 2009-2011 ARM Limited. All rights reserved. 3 | * 4 | * A generic CMSIS include header, pulling in LPC11U24 specifics 5 | */ 6 | 7 | #ifndef MBED_CMSIS_H 8 | #define MBED_CMSIS_H 9 | 10 | #include "fsl_device_registers.h" 11 | #include "cmsis_nvic.h" 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /Deployment/release_O3.json: -------------------------------------------------------------------------------- 1 | { 2 | "GCC_ARM": { 3 | "common": ["-c", "-Wall", "-Wextra", 4 | "-Wno-unused-parameter", "-Wno-missing-field-initializers", 5 | "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", 6 | "-ffunction-sections", "-fdata-sections", "-funsigned-char", 7 | "-MMD", "-fno-delete-null-pointer-checks", 8 | "-fomit-frame-pointer", "-O3", "-DNDEBUG", "-g1"], 9 | "asm": ["-x", "assembler-with-cpp"], 10 | "c": ["-std=gnu99"], 11 | "cxx": ["-std=gnu++98", "-fno-rtti", "-Wvla"], 12 | "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", 13 | "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r", 14 | "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", 15 | "-Wl,-n"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_sleep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, ARM Limited, All Rights Reserved 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #ifndef MBED_MBED_SLEEP_H 18 | #define MBED_MBED_SLEEP_H 19 | 20 | #warning mbed_sleep.h has been replaced by mbed_power_mgmt.h, please update to mbed_power_mgmt.h [since mbed-os-5.8] 21 | #include "platform/mbed_power_mgmt.h" 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/sleep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef MBED_OLD_SLEEP_H 19 | #define MBED_OLD_SLEEP_H 20 | 21 | #warning sleep.h has been replaced by mbed_power_mgmt.h, please update to mbed_power_mgmt.h [since mbed-os-5.8] 22 | #include "platform/mbed_power_mgmt.h" 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/critical.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef MBED_OLD_CRITICAL_H 19 | #define MBED_OLD_CRITICAL_H 20 | 21 | #warning critical.h has been replaced by mbed_critical.h, please update to mbed_critical.h [since mbed-os-5.3] 22 | #include "platform/mbed_critical.h" 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/rtc_time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef MBED_OLD_RTC_TIME_H 19 | #define MBED_OLD_RTC_TIME_H 20 | 21 | #warning rtc_time.h has been replaced by mbed_rtc_time.h, please update to mbed_rtc_time.h [since mbed-os-5.3] 22 | #include "platform/mbed_rtc_time.h" 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/wait_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef MBED_OLD_WAIT_API_H 19 | #define MBED_OLD_WAIT_API_H 20 | 21 | #warning wait_api.h has been replaced by mbed_wait_api.h, please update to mbed_wait_api.h [since mbed-os-5.3] 22 | #include "platform/mbed_wait_api.h" 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/semihost_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef MBED_OLD_SEMIHOST_API_H 19 | #define MBED_OLD_SEMIHOST_API_H 20 | 21 | #warning semihost_api.h has been replaced by mbed_semihost_api.h, please update to mbed_semihost_api.h [since mbed-os-5.3] 22 | #include "platform/mbed_semihost_api.h" 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Deployment/Source/KWS/KWS_DNN/kws_dnn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __KWS_DNN_H__ 20 | #define __KWS_DNN_H__ 21 | 22 | #include "kws.h" 23 | #include "dnn.h" 24 | 25 | class KWS_DNN : public KWS { 26 | public: 27 | KWS_DNN(int recording_win, int sliding_window_len); 28 | KWS_DNN(int16_t* audio_buffer); 29 | ~KWS_DNN(); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/toolchain.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup platform */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef MBED_OLD_TOOLCHAIN_H 21 | #define MBED_OLD_TOOLCHAIN_H 22 | 23 | #warning toolchain.h has been replaced by mbed_toolchain.h, please update to mbed_toolchain.h [since mbed-os-5.3] 24 | #include "platform/mbed_toolchain.h" 25 | 26 | #endif 27 | 28 | /** @}*/ 29 | -------------------------------------------------------------------------------- /Deployment/Source/KWS/KWS_DS_CNN/kws_ds_cnn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __KWS_DS_CNN_H__ 20 | #define __KWS_DS_CNN_H__ 21 | 22 | #include "kws.h" 23 | #include "ds_cnn.h" 24 | 25 | class KWS_DS_CNN : public KWS { 26 | public: 27 | KWS_DS_CNN(int recording_win, int sliding_window_len); 28 | KWS_DS_CNN(int16_t* audio_buffer); 29 | ~KWS_DS_CNN(); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/PortNames.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_PORTNAMES_H 17 | #define MBED_PORTNAMES_H 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef enum { 24 | PortA = 0, 25 | PortB = 1, 26 | PortC = 2, 27 | PortD = 3, 28 | PortE = 4 29 | } PortName; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/gpio_object.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_GPIO_OBJECT_H 17 | #define MBED_GPIO_OBJECT_H 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef struct { 24 | PinName pin; 25 | } gpio_t; 26 | 27 | static inline int gpio_is_connected(const gpio_t *obj) 28 | { 29 | return obj->pin != (PinName)NC; 30 | } 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/platform.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup platform */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_PLATFORM_H 20 | #define MBED_PLATFORM_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "platform/mbed_retarget.h" 28 | #include "platform/mbed_toolchain.h" 29 | #include "device.h" 30 | #include "PinNames.h" 31 | #include "PeripheralNames.h" 32 | 33 | #endif 34 | 35 | /** @}*/ 36 | -------------------------------------------------------------------------------- /Deployment/Examples/realtime_test/plot_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "kws_f746ng.h" 20 | #include "LCD_DISCO_F746NG.h" 21 | 22 | #define LCD_COLOR_ARM_BLUE ((uint32_t) 0xFF00C1DE) 23 | #define LCD_COLOR_ARM_DARK ((uint32_t) 0xFF333E48) 24 | 25 | extern LCD_DISCO_F746NG lcd; 26 | extern KWS_F746NG *kws; 27 | 28 | void init_plot(); 29 | void plot_mfcc(); 30 | void plot_waveform(); 31 | uint32_t calculate_rgb(int min, int max, int value); 32 | 33 | 34 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/device.h: -------------------------------------------------------------------------------- 1 | // The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches. 2 | // Check the 'features' section of the target description in 'targets.json' for more details. 3 | /* mbed Microcontroller Library 4 | * Copyright (c) 2006-2013 ARM Limited 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef MBED_DEVICE_H 19 | #define MBED_DEVICE_H 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | #define DEVICE_ID_LENGTH 24 32 | 33 | 34 | 35 | 36 | 37 | #include "objects.h" 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Deployment/Source/NN/nn.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "nn.h" 20 | 21 | NN::~NN() { 22 | } 23 | 24 | int NN::get_frame_len() { 25 | return frame_len; 26 | } 27 | 28 | int NN::get_frame_shift() { 29 | return frame_shift; 30 | } 31 | 32 | int NN::get_num_mfcc_features() { 33 | return num_mfcc_features; 34 | } 35 | 36 | int NN::get_num_frames() { 37 | return num_frames; 38 | } 39 | 40 | int NN::get_num_out_classes() { 41 | return num_out_classes; 42 | } 43 | 44 | int NN::get_in_dec_bits() { 45 | return in_dec_bits; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/buffer.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2014-2015 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_BUFFER_H 20 | #define MBED_BUFFER_H 21 | 22 | #include 23 | 24 | /** Generic buffer structure 25 | */ 26 | typedef struct buffer_s { 27 | void *buffer; /**< the pointer to a buffer */ 28 | size_t length; /**< the buffer length */ 29 | size_t pos; /**< actual buffer position */ 30 | uint8_t width; /**< The buffer unit width (8, 16, 32, 64), used for proper *buffer casting */ 31 | } buffer_t; 32 | 33 | #endif 34 | 35 | /** @}*/ 36 | -------------------------------------------------------------------------------- /Deployment/Source/KWS/KWS_DNN/kws_dnn.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #include "kws_dnn.h" 21 | 22 | KWS_DNN::KWS_DNN(int record_win, int sliding_win_len) 23 | { 24 | nn = new DNN(); 25 | recording_win = record_win; 26 | sliding_window_len = sliding_win_len; 27 | init_kws(); 28 | } 29 | 30 | KWS_DNN::KWS_DNN(int16_t* audio_data_buffer) 31 | { 32 | nn = new DNN(); 33 | audio_buffer = audio_data_buffer; 34 | recording_win = nn->get_num_frames(); 35 | sliding_window_len = 1; 36 | init_kws(); 37 | } 38 | 39 | KWS_DNN::~KWS_DNN() 40 | { 41 | delete nn; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Deployment/Source/KWS/KWS_DS_CNN/kws_ds_cnn.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | 20 | #include "kws_ds_cnn.h" 21 | 22 | KWS_DS_CNN::KWS_DS_CNN(int record_win, int sliding_win_len) 23 | { 24 | nn = new DS_CNN(); 25 | recording_win = record_win; 26 | sliding_window_len = sliding_win_len; 27 | init_kws(); 28 | } 29 | 30 | KWS_DS_CNN::KWS_DS_CNN(int16_t* audio_data_buffer) 31 | { 32 | nn = new DS_CNN(); 33 | audio_buffer = audio_data_buffer; 34 | recording_win = nn->get_num_frames(); 35 | sliding_window_len = 1; 36 | init_kws(); 37 | } 38 | 39 | KWS_DS_CNN::~KWS_DS_CNN() 40 | { 41 | delete nn; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/TableCRC.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2017 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef TABLE_CRC_H 18 | #define TABLE_CRC_H 19 | 20 | #include 21 | 22 | namespace mbed { 23 | /** \addtogroup drivers */ 24 | /** @{*/ 25 | 26 | #define MBED_CRC_TABLE_SIZE 256 27 | 28 | extern const uint8_t Table_CRC_7Bit_SD[MBED_CRC_TABLE_SIZE]; 29 | extern const uint8_t Table_CRC_8bit_CCITT[MBED_CRC_TABLE_SIZE]; 30 | extern const uint16_t Table_CRC_16bit_CCITT[MBED_CRC_TABLE_SIZE]; 31 | extern const uint16_t Table_CRC_16bit_IBM[MBED_CRC_TABLE_SIZE]; 32 | extern const uint32_t Table_CRC_32bit_ANSI[MBED_CRC_TABLE_SIZE]; 33 | 34 | /** @}*/ 35 | } // namespace mbed 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Deployment/Source/NN/nn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __NN_H__ 20 | #define __NN_H__ 21 | 22 | #include "arm_nnfunctions.h" 23 | 24 | class NN { 25 | 26 | public: 27 | virtual ~NN(); 28 | virtual void run_nn(q7_t* in_data, q7_t* out_data)=0; 29 | int get_num_mfcc_features(); 30 | int get_num_frames(); 31 | int get_frame_len(); 32 | int get_frame_shift(); 33 | int get_num_out_classes(); 34 | int get_in_dec_bits(); 35 | 36 | protected: 37 | int frame_len; 38 | int frame_shift; 39 | int num_mfcc_features; 40 | int num_frames; 41 | int num_out_classes; 42 | int in_dec_bits; 43 | 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/dma_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2014-2015 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_DMA_API_H 20 | #define MBED_DMA_API_H 21 | 22 | #include 23 | 24 | #define DMA_ERROR_OUT_OF_CHANNELS (-1) 25 | 26 | typedef enum { 27 | DMA_USAGE_NEVER, 28 | DMA_USAGE_OPPORTUNISTIC, 29 | DMA_USAGE_ALWAYS, 30 | DMA_USAGE_TEMPORARY_ALLOCATED, 31 | DMA_USAGE_ALLOCATED 32 | } DMAUsage; 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | void dma_init(void); 39 | 40 | int dma_channel_allocate(uint32_t capabilities); 41 | 42 | int dma_channel_free(int channelid); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | 50 | /** @}*/ 51 | -------------------------------------------------------------------------------- /Deployment/Source/KWS_F746NG/kws_f746ng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __KWS_F746NG_H__ 20 | #define __KWS_F746NG_H__ 21 | 22 | #include "AUDIO_DISCO_F746NG.h" 23 | #include "kws_ds_cnn.h" 24 | //#include "kws_dnn.h" 25 | 26 | // Change the parent class to KWS_DNN to switch to DNN model 27 | //class KWS_F746NG : public KWS_DNN { 28 | class KWS_F746NG : public KWS_DS_CNN { 29 | public: 30 | KWS_F746NG(int recording_win, int sliding_window_len); 31 | ~KWS_F746NG(); 32 | void start_kws(); 33 | void set_volume(int vol); 34 | int16_t* audio_buffer_in; 35 | //for debugging: microphone to headphone loopback 36 | int16_t* audio_buffer_out; 37 | 38 | private: 39 | AUDIO_DISCO_F746NG audio; 40 | 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/LowPowerTimer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LOWPOWERTIMER_H 17 | #define MBED_LOWPOWERTIMER_H 18 | 19 | #include "platform/platform.h" 20 | #include "drivers/Timer.h" 21 | #include "platform/NonCopyable.h" 22 | 23 | #if defined (DEVICE_LOWPOWERTIMER) || defined(DOXYGEN_ONLY) 24 | 25 | #include "hal/lp_ticker_api.h" 26 | 27 | namespace mbed { 28 | /** \addtogroup drivers */ 29 | 30 | /** Low power timer 31 | * 32 | * @note Synchronization level: Interrupt safe 33 | * @ingroup drivers 34 | */ 35 | class LowPowerTimer : public Timer, private NonCopyable { 36 | 37 | public: 38 | LowPowerTimer() : Timer(get_lp_ticker_data()) { 39 | } 40 | 41 | }; 42 | 43 | } // namespace mbed 44 | 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/LowPowerTimeout.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LOWPOWERTIMEOUT_H 17 | #define MBED_LOWPOWERTIMEOUT_H 18 | 19 | #include "platform/platform.h" 20 | 21 | #if defined (DEVICE_LOWPOWERTIMER) || defined(DOXYGEN_ONLY) 22 | 23 | #include "hal/lp_ticker_api.h" 24 | #include "drivers/LowPowerTicker.h" 25 | #include "platform/NonCopyable.h" 26 | 27 | namespace mbed { 28 | /** \addtogroup drivers */ 29 | 30 | /** Low Power Timout 31 | * 32 | * @note Synchronization level: Interrupt safe 33 | * @ingroup drivers 34 | */ 35 | class LowPowerTimeout : public LowPowerTicker, private NonCopyable { 36 | 37 | private: 38 | virtual void handler(void) { 39 | _function.call(); 40 | } 41 | }; 42 | 43 | } 44 | 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/LowPowerTicker.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LOWPOWERTICKER_H 17 | #define MBED_LOWPOWERTICKER_H 18 | 19 | #include "platform/platform.h" 20 | #include "drivers/Ticker.h" 21 | #include "platform/NonCopyable.h" 22 | 23 | #if defined (DEVICE_LOWPOWERTIMER) || defined(DOXYGEN_ONLY) 24 | 25 | #include "hal/lp_ticker_api.h" 26 | 27 | namespace mbed { 28 | /** \addtogroup drivers */ 29 | 30 | /** Low Power Ticker 31 | * 32 | * @note Synchronization level: Interrupt safe 33 | * @ingroup drivers 34 | */ 35 | class LowPowerTicker : public Ticker, private NonCopyable { 36 | 37 | public: 38 | LowPowerTicker() : Ticker(get_lp_ticker_data()) { 39 | } 40 | 41 | virtual ~LowPowerTicker() { 42 | } 43 | }; 44 | 45 | } // namespace mbed 46 | 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mbed SDK 3 | * Copyright (c) 2017 ARM Limited 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Automatically generated configuration file. 19 | // DO NOT EDIT, content will be overwritten. 20 | 21 | #ifndef __MBED_CONFIG_DATA__ 22 | #define __MBED_CONFIG_DATA__ 23 | 24 | // Configuration parameters 25 | #define MBED_CONF_PLATFORM_STDIO_CONVERT_TTY_NEWLINES 0 // set by library:platform 26 | #define MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE 9600 // set by library:platform 27 | #define MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES 0 // set by library:platform 28 | #define MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR 0 // set by library:platform 29 | #define MBED_CONF_PLATFORM_STDIO_BAUD_RATE 9600 // set by library:platform 30 | #define MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL 0 // set by library:platform 31 | #define MBED_CONF_PLATFORM_STDIO_FLUSH_AT_EXIT 1 // set by library:platform 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Deployment/Source/KWS/kws.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __KWS_H__ 20 | #define __KWS_H__ 21 | 22 | #include "mbed.h" 23 | #include "nn.h" 24 | #include "mfcc.h" 25 | 26 | class KWS{ 27 | 28 | public: 29 | ~KWS(); 30 | void extract_features(); 31 | void classify(); 32 | void average_predictions(); 33 | int get_top_class(q7_t* prediction); 34 | int16_t* audio_buffer; 35 | q7_t *mfcc_buffer; 36 | q7_t *output; 37 | q7_t *predictions; 38 | q7_t *averaged_output; 39 | int num_frames; 40 | int num_mfcc_features; 41 | int frame_len; 42 | int frame_shift; 43 | int num_out_classes; 44 | int audio_block_size; 45 | int audio_buffer_size; 46 | 47 | protected: 48 | KWS(); 49 | void init_kws(); 50 | MFCC *mfcc; 51 | NN *nn; 52 | int mfcc_buffer_size; 53 | int recording_win; 54 | int sliding_window_len; 55 | 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/PlatformMutex.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup platform */ 3 | /** @{*/ 4 | /** 5 | * \defgroup platform_PlatformMutex PlatformMutex class 6 | * @{ 7 | */ 8 | /* mbed Microcontroller Library 9 | * Copyright (c) 2006-2013 ARM Limited 10 | * 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 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | #ifndef PLATFORM_MUTEX_H 24 | #define PLATFORM_MUTEX_H 25 | 26 | #include "platform/NonCopyable.h" 27 | 28 | #ifdef MBED_CONF_RTOS_PRESENT 29 | #include "rtos/Mutex.h" 30 | typedef rtos::Mutex PlatformMutex; 31 | #else 32 | /** A stub mutex for when an RTOS is not present 33 | */ 34 | class PlatformMutex : private mbed::NonCopyable { 35 | public: 36 | PlatformMutex() { 37 | // Stub 38 | 39 | } 40 | ~PlatformMutex() { 41 | // Stub 42 | } 43 | 44 | void lock() { 45 | // Do nothing 46 | } 47 | 48 | void unlock() { 49 | // Do nothing 50 | } 51 | }; 52 | 53 | #endif 54 | 55 | #endif 56 | 57 | /**@}*/ 58 | 59 | /**@}*/ 60 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/pinmap.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_PINMAP_H 20 | #define MBED_PINMAP_H 21 | 22 | #include "PinNames.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | typedef struct { 29 | PinName pin; 30 | int peripheral; 31 | int function; 32 | } PinMap; 33 | 34 | void pin_function(PinName pin, int function); 35 | void pin_mode (PinName pin, PinMode mode); 36 | 37 | uint32_t pinmap_peripheral(PinName pin, const PinMap* map); 38 | uint32_t pinmap_function(PinName pin, const PinMap* map); 39 | uint32_t pinmap_merge (uint32_t a, uint32_t b); 40 | void pinmap_pinout (PinName pin, const PinMap *map); 41 | uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map); 42 | uint32_t pinmap_find_function(PinName pin, const PinMap* map); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | 50 | /** @}*/ 51 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* 20 | * Description: Example code for running keyword spotting on Cortex-M boards 21 | */ 22 | 23 | #include "kws_ds_cnn.h" 24 | #include "wav_data.h" 25 | 26 | int16_t audio_buffer[16000]=WAVE_DATA; 27 | 28 | Timer T; 29 | Serial pc(USBTX, USBRX); 30 | 31 | int main() 32 | { 33 | char output_class[12][8] = {"Silence", "Unknown","yes","no","up","down","left","right","on","off","stop","go"}; 34 | KWS_DS_CNN kws(audio_buffer); 35 | 36 | T.start(); 37 | int start=T.read_us(); 38 | kws.extract_features(); //extract mfcc features 39 | kws.classify(); //classify using dnn 40 | int end=T.read_us(); 41 | T.stop(); 42 | int max_ind = kws.get_top_class(kws.output); 43 | pc.printf("Total time : %d us\r\n",end-start); 44 | printf("Detected %s (%d%%)\r\n",output_class[max_ind],((int)kws.output[max_ind]*100/128)); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/mbed_lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "platform", 3 | "config": { 4 | "stdio-convert-newlines": { 5 | "help": "Enable conversion to standard newlines on stdin/stdout/stderr", 6 | "value": false 7 | }, 8 | 9 | "stdio-convert-tty-newlines": { 10 | "help": "Enable conversion to standard newlines on any tty FILE stream", 11 | "value": false 12 | }, 13 | 14 | "stdio-buffered-serial": { 15 | "help": "Use UARTSerial driver to obtain buffered serial I/O on stdin/stdout/stderr. If false, unbuffered serial_getc and serial_putc are used directly.", 16 | "value": false 17 | }, 18 | 19 | "stdio-baud-rate": { 20 | "help": "Baud rate for stdio", 21 | "value": 9600 22 | }, 23 | 24 | "stdio-flush-at-exit": { 25 | "help": "Enable or disable the flush of standard I/O's at exit.", 26 | "value": true 27 | }, 28 | 29 | "default-serial-baud-rate": { 30 | "help": "Default baud rate for a Serial or RawSerial instance (if not specified in the constructor)", 31 | "value": 9600 32 | }, 33 | 34 | "force-non-copyable-error": { 35 | "help": "Force compile time error when a NonCopyable object is copied", 36 | "value": false 37 | } 38 | }, 39 | "target_overrides": { 40 | "EFM32": { 41 | "stdio-baud-rate": 115200 42 | }, 43 | "EFR32": { 44 | "stdio-baud-rate": 115200 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Deployment/Source/local_NN/local_NN.h: -------------------------------------------------------------------------------- 1 | #include "arm_nnsupportfunctions.h" 2 | #include "arm_nn_tables.h" 3 | 4 | #define USE_INTRINSIC 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #endif 10 | 11 | arm_status arm_convolve_HWC_q7_basic_nonsquare(const q7_t * Im_in, 12 | const uint16_t dim_im_in_X, 13 | const uint16_t dim_im_in_Y, 14 | const uint16_t ch_im_in, 15 | const q7_t * wt, 16 | const uint16_t ch_im_out, 17 | const uint16_t dim_kernel_X, 18 | const uint16_t dim_kernel_Y, 19 | const uint16_t padding_X, 20 | const uint16_t padding_Y, 21 | const uint16_t stride_X, 22 | const uint16_t stride_Y, 23 | const q7_t * bias, 24 | const uint16_t bias_shift, 25 | const uint16_t out_shift, 26 | q7_t * Im_out, 27 | const uint16_t dim_im_out_X, 28 | const uint16_t dim_im_out_Y, 29 | q15_t * bufferA, 30 | q7_t * bufferB); 31 | 32 | void arm_avepool_q7_HWC_nonsquare ( 33 | const q7_t * Im_in, 34 | const uint16_t dim_im_in_x, 35 | const uint16_t dim_im_in_y, 36 | const uint16_t ch_im_in, 37 | const uint16_t dim_kernel_x, 38 | const uint16_t dim_kernel_y, 39 | const uint16_t padding_x, 40 | const uint16_t padding_y, 41 | const uint16_t stride_x, 42 | const uint16_t stride_y, 43 | const uint16_t dim_im_out_x, 44 | const uint16_t dim_im_out_y, 45 | q7_t * bufferA, 46 | q7_t * Im_out, 47 | const uint16_t out_lshift); 48 | 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | 55 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/FileLike.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILELIKE_H 17 | #define MBED_FILELIKE_H 18 | 19 | #include "platform/mbed_toolchain.h" 20 | #include "platform/FileBase.h" 21 | #include "platform/FileHandle.h" 22 | #include "platform/NonCopyable.h" 23 | 24 | namespace mbed { 25 | /** \addtogroup platform */ 26 | /** @{*/ 27 | /** 28 | * \defgroup platform_FileLike FileLike class 29 | * @{ 30 | */ 31 | /** Class FileLike 32 | * 33 | * A file-like object is one that can be opened with fopen by 34 | * fopen("/name", mode). 35 | * 36 | * @note Synchronization level: Set by subclass 37 | */ 38 | class FileLike : public FileHandle, public FileBase, private NonCopyable { 39 | public: 40 | /** Constructor FileLike 41 | * 42 | * @param name The name to use to open the file. 43 | */ 44 | FileLike(const char *name = NULL) : FileBase(name, FilePathType) {} 45 | virtual ~FileLike() {} 46 | }; 47 | 48 | /**@}*/ 49 | 50 | /**@}*/ 51 | 52 | } // namespace mbed 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/FilePath.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILEPATH_H 17 | #define MBED_FILEPATH_H 18 | 19 | #include "platform/platform.h" 20 | 21 | #include "platform/FileSystemLike.h" 22 | #include "platform/FileLike.h" 23 | 24 | namespace mbed { 25 | /** \addtogroup platform */ 26 | /** @{*/ 27 | /** 28 | * \defgroup platform_FilePath FilePath class 29 | * @{ 30 | */ 31 | 32 | class FileSystem; 33 | /** Class FilePath 34 | * 35 | */ 36 | 37 | class FilePath { 38 | public: 39 | /** Constructor FilePath 40 | * 41 | * @param file_path The path of file. 42 | */ 43 | FilePath(const char* file_path); 44 | 45 | const char* fileName(void); 46 | 47 | bool isFileSystem(void); 48 | FileSystemLike* fileSystem(void); 49 | 50 | bool isFile(void); 51 | FileLike* file(void); 52 | bool exists(void); 53 | 54 | private: 55 | const char* file_name; 56 | FileBase* fb; 57 | }; 58 | 59 | /**@}*/ 60 | 61 | /**@}*/ 62 | 63 | } // namespace mbed 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/PeripheralPins.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef MBED_PERIPHERALPINS_H 18 | #define MBED_PERIPHERALPINS_H 19 | 20 | #include "pinmap.h" 21 | #include "PeripheralNames.h" 22 | 23 | /************RTC***************/ 24 | extern const PinMap PinMap_RTC[]; 25 | 26 | /************ADC***************/ 27 | extern const PinMap PinMap_ADC[]; 28 | 29 | /************DAC***************/ 30 | extern const PinMap PinMap_DAC[]; 31 | 32 | /************I2C***************/ 33 | extern const PinMap PinMap_I2C_SDA[]; 34 | extern const PinMap PinMap_I2C_SCL[]; 35 | 36 | /************UART***************/ 37 | extern const PinMap PinMap_UART_TX[]; 38 | extern const PinMap PinMap_UART_RX[]; 39 | extern const PinMap PinMap_UART_CTS[]; 40 | extern const PinMap PinMap_UART_RTS[]; 41 | /************SPI***************/ 42 | extern const PinMap PinMap_SPI_SCLK[]; 43 | extern const PinMap PinMap_SPI_MOSI[]; 44 | extern const PinMap PinMap_SPI_MISO[]; 45 | extern const PinMap PinMap_SPI_SSEL[]; 46 | 47 | /************PWM***************/ 48 | extern const PinMap PinMap_PWM[]; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/rtc_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_RTC_API_H 20 | #define MBED_RTC_API_H 21 | 22 | #include "device.h" 23 | 24 | #if DEVICE_RTC 25 | 26 | #include 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** 33 | * \defgroup hal_rtc RTC hal functions 34 | * @{ 35 | */ 36 | 37 | /** Initialize the RTC peripheral 38 | * 39 | */ 40 | void rtc_init(void); 41 | 42 | /** Deinitialize RTC 43 | * 44 | * TODO: The function is not used by rtc api in mbed-drivers. 45 | */ 46 | void rtc_free(void); 47 | 48 | /** Get the RTC enable status 49 | * 50 | * @retval 0 disabled 51 | * @retval 1 enabled 52 | */ 53 | int rtc_isenabled(void); 54 | 55 | /** Get the current time from the RTC peripheral 56 | * 57 | * @return The current time 58 | */ 59 | time_t rtc_read(void); 60 | 61 | /** Set the current time to the RTC peripheral 62 | * 63 | * @param t The current time to be set 64 | */ 65 | void rtc_write(time_t t); 66 | 67 | /**@}*/ 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif 74 | 75 | #endif 76 | 77 | /** @}*/ 78 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/Timeout.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_TIMEOUT_H 17 | #define MBED_TIMEOUT_H 18 | 19 | #include "drivers/Ticker.h" 20 | #include "platform/NonCopyable.h" 21 | #include "platform/mbed_power_mgmt.h" 22 | 23 | namespace mbed { 24 | /** \addtogroup drivers */ 25 | 26 | /** A Timeout is used to call a function at a point in the future 27 | * 28 | * You can use as many seperate Timeout objects as you require. 29 | * 30 | * @note Synchronization level: Interrupt safe 31 | * 32 | * Example: 33 | * @code 34 | * // Blink until timeout. 35 | * 36 | * #include "mbed.h" 37 | * 38 | * Timeout timeout; 39 | * DigitalOut led(LED1); 40 | * 41 | * int on = 1; 42 | * 43 | * void attimeout() { 44 | * on = 0; 45 | * } 46 | * 47 | * int main() { 48 | * timeout.attach(&attimeout, 5); 49 | * while(on) { 50 | * led = !led; 51 | * wait(0.2); 52 | * } 53 | * } 54 | * @endcode 55 | * @ingroup drivers 56 | */ 57 | class Timeout : public Ticker, private NonCopyable { 58 | 59 | protected: 60 | virtual void handler(); 61 | }; 62 | 63 | } // namespace mbed 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_application.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2017-2017 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef MBED_APPLICATION_H 18 | #define MBED_APPLICATION_H 19 | 20 | #include 21 | 22 | #if defined(__CORTEX_M3) || defined(__CORTEX_M4) || defined(__CORTEX_M7) 23 | #define MBED_APPLICATION_SUPPORT 1 24 | #else 25 | #define MBED_APPLICATION_SUPPORT 0 26 | #endif 27 | 28 | #if MBED_APPLICATION_SUPPORT 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * Start the application at the given address. This function does 35 | * not return. It is the applications responsibility for flushing to 36 | * or powering down external components such as filesystems or 37 | * socket connections before calling this function. For Cortex-M 38 | * devices this function powers down generic system components such as 39 | * the NVIC and set the vector table to that of the new image followed 40 | * by jumping to the reset handler of the new image. 41 | * 42 | * @param address Starting address of next application to run 43 | */ 44 | void mbed_start_application(uintptr_t address); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 0U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Deployment/Source/local_NN/arm_avepool_q7_HWC_nonsquare.c: -------------------------------------------------------------------------------- 1 | #include "arm_math.h" 2 | #include "arm_nnfunctions.h" 3 | 4 | 5 | void arm_avepool_q7_HWC_nonsquare ( 6 | const q7_t * Im_in, // input image 7 | const uint16_t dim_im_in_x, // input image dimension 8 | const uint16_t dim_im_in_y, // input image dimension 9 | const uint16_t ch_im_in, // number of input image channels 10 | const uint16_t dim_kernel_x, // window kernel size 11 | const uint16_t dim_kernel_y, // window kernel size 12 | const uint16_t padding_x, // padding sizes 13 | const uint16_t padding_y, // padding sizes 14 | const uint16_t stride_x, // stride 15 | const uint16_t stride_y, // stride 16 | const uint16_t dim_im_out_x, // output image dimension 17 | const uint16_t dim_im_out_y, // output image dimension 18 | q7_t * bufferA, // a buffer for local storage 19 | q7_t * Im_out, // output feature 20 | const uint16_t out_lshift) // output left shift (scaling) 21 | { 22 | int16_t i_ch_in, i_x, i_y; 23 | int16_t k_x, k_y; 24 | 25 | for(i_ch_in=0;i_ch_in= 0 && k_x >= 0 && k_y 23 | #include "device.h" 24 | 25 | #if DEVICE_TRNG 26 | 27 | /** TRNG HAL structure. trng_s is declared in the target's HAL 28 | */ 29 | typedef struct trng_s trng_t; 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /** 36 | * \defgroup hal_trng TRNG hal functions 37 | * @{ 38 | */ 39 | 40 | /** Initialize the TRNG peripheral 41 | * 42 | * @param obj The TRNG object 43 | */ 44 | void trng_init(trng_t *obj); 45 | 46 | /** Deinitialize the TRNG peripheral 47 | * 48 | * @param obj The TRNG object 49 | */ 50 | void trng_free(trng_t *obj); 51 | 52 | /** Get random data from TRNG peripheral 53 | * 54 | * @param obj The TRNG object 55 | * @param output The pointer to an output array 56 | * @param length The size of output data, to avoid buffer overwrite 57 | * @param output_length The length of generated data 58 | * @return 0 success, -1 fail 59 | */ 60 | int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length); 61 | 62 | /**@}*/ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif 69 | 70 | #endif 71 | 72 | /** @}*/ 73 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/ethernet_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_ETHERNET_API_H 20 | #define MBED_ETHERNET_API_H 21 | 22 | #include "device.h" 23 | 24 | #if DEVICE_ETHERNET 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | // Connection constants 31 | 32 | int ethernet_init(void); 33 | void ethernet_free(void); 34 | 35 | // write size bytes from data to ethernet buffer 36 | // return num bytes written 37 | // or -1 if size is too big 38 | int ethernet_write(const char *data, int size); 39 | 40 | // send ethernet write buffer, returning the packet size sent 41 | int ethernet_send(void); 42 | 43 | // receive from ethernet buffer, returning packet size, or 0 if no packet 44 | int ethernet_receive(void); 45 | 46 | // read size bytes in to data, return actual num bytes read (0..size) 47 | // if data == NULL, throw the bytes away 48 | int ethernet_read(char *data, int size); 49 | 50 | // get the ethernet address 51 | void ethernet_address(char *mac); 52 | 53 | // see if the link is up 54 | int ethernet_link(void); 55 | 56 | // force link settings 57 | void ethernet_set_link(int speed, int duplex); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif 64 | 65 | #endif 66 | 67 | 68 | /** @}*/ 69 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_wait_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup platform */ 3 | /** @{*/ 4 | /** 5 | * \defgroup platform_wait_api wait_api functions 6 | * @{ 7 | */ 8 | 9 | /* mbed Microcontroller Library 10 | * Copyright (c) 2006-2013 ARM Limited 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | #ifndef MBED_WAIT_API_H 25 | #define MBED_WAIT_API_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /** Generic wait functions. 32 | * 33 | * These provide simple NOP type wait capabilities. 34 | * 35 | * Example: 36 | * @code 37 | * #include "mbed.h" 38 | * 39 | * DigitalOut heartbeat(LED1); 40 | * 41 | * int main() { 42 | * while (1) { 43 | * heartbeat = 1; 44 | * wait(0.5); 45 | * heartbeat = 0; 46 | * wait(0.5); 47 | * } 48 | * } 49 | * @endcode 50 | */ 51 | 52 | /** Waits for a number of seconds, with microsecond resolution (within 53 | * the accuracy of single precision floating point). 54 | * 55 | * @param s number of seconds to wait 56 | */ 57 | void wait(float s); 58 | 59 | /** Waits a number of milliseconds. 60 | * 61 | * @param ms the whole number of milliseconds to wait 62 | */ 63 | void wait_ms(int ms); 64 | 65 | /** Waits a number of microseconds. 66 | * 67 | * @param us the whole number of microseconds to wait 68 | */ 69 | void wait_us(int us); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif 76 | 77 | /** @}*/ 78 | /** @}*/ 79 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/can_helper.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_CAN_HELPER_H 20 | #define MBED_CAN_HELPER_H 21 | 22 | #if DEVICE_CAN 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * 30 | * \enum CANFormat 31 | * 32 | * \brief Values that represent CAN Format 33 | **/ 34 | enum CANFormat { 35 | CANStandard = 0, 36 | CANExtended = 1, 37 | CANAny = 2 38 | }; 39 | typedef enum CANFormat CANFormat; 40 | 41 | /** 42 | * 43 | * \enum CANType 44 | * 45 | * \brief Values that represent CAN Type 46 | **/ 47 | enum CANType { 48 | CANData = 0, 49 | CANRemote = 1 50 | }; 51 | typedef enum CANType CANType; 52 | 53 | /** 54 | * 55 | * \struct CAN_Message 56 | * 57 | * \brief Holder for single CAN message. 58 | * 59 | **/ 60 | struct CAN_Message { 61 | unsigned int id; // 29 bit identifier 62 | unsigned char data[8]; // Data field 63 | unsigned char len; // Length of data field in bytes 64 | CANFormat format; // Format ::CANFormat 65 | CANType type; // Type ::CANType 66 | }; 67 | typedef struct CAN_Message CAN_Message; 68 | 69 | #ifdef __cplusplus 70 | }; 71 | #endif 72 | 73 | #endif 74 | 75 | #endif // MBED_CAN_HELPER_H 76 | 77 | /** @}*/ 78 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/FileBase.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILEBASE_H 17 | #define MBED_FILEBASE_H 18 | 19 | typedef int FILEHANDLE; 20 | 21 | #include 22 | #include 23 | 24 | #include "platform/platform.h" 25 | #include "platform/SingletonPtr.h" 26 | #include "platform/PlatformMutex.h" 27 | #include "platform/NonCopyable.h" 28 | 29 | namespace mbed { 30 | 31 | typedef enum { 32 | FilePathType, 33 | FileSystemPathType 34 | } PathType; 35 | 36 | /** \addtogroup platform */ 37 | /** @{*/ 38 | /** 39 | * \defgroup platform_FileBase FileBase class 40 | * @{ 41 | */ 42 | /** Class FileBase 43 | * 44 | */ 45 | 46 | class FileBase : private NonCopyable { 47 | public: 48 | FileBase(const char *name, PathType t); 49 | virtual ~FileBase(); 50 | 51 | const char* getName(void); 52 | PathType getPathType(void); 53 | 54 | static FileBase *lookup(const char *name, unsigned int len); 55 | 56 | static FileBase *get(int n); 57 | 58 | /* disallow copy constructor and assignment operators */ 59 | private: 60 | static FileBase *_head; 61 | static SingletonPtr _mutex; 62 | 63 | FileBase *_next; 64 | const char * const _name; 65 | const PathType _path_type; 66 | }; 67 | 68 | /**@}*/ 69 | 70 | /**@}*/ 71 | 72 | } // namespace mbed 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /Deployment/Source/MFCC/mfcc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __KWS_MFCC_H__ 20 | #define __KWS_MFCC_H__ 21 | 22 | #include "arm_math.h" 23 | #include "string.h" 24 | 25 | #define SAMP_FREQ 16000 26 | #define NUM_FBANK_BINS 40 27 | #define MEL_LOW_FREQ 20 28 | #define MEL_HIGH_FREQ 4000 29 | 30 | #define M_2PI 6.283185307179586476925286766559005 31 | 32 | class MFCC{ 33 | private: 34 | int num_mfcc_features; 35 | int frame_len; 36 | int frame_len_padded; 37 | int mfcc_dec_bits; 38 | float * frame; 39 | float * buffer; 40 | float * mel_energies; 41 | float * window_func; 42 | int32_t * fbank_filter_first; 43 | int32_t * fbank_filter_last; 44 | float ** mel_fbank; 45 | float * dct_matrix; 46 | arm_rfft_fast_instance_f32 * rfft; 47 | float * create_dct_matrix(int32_t input_length, int32_t coefficient_count); 48 | float ** create_mel_fbank(); 49 | 50 | static inline float InverseMelScale(float mel_freq) { 51 | return 700.0f * (expf (mel_freq / 1127.0f) - 1.0f); 52 | } 53 | 54 | static inline float MelScale(float freq) { 55 | return 1127.0f * logf (1.0f + freq / 700.0f); 56 | } 57 | 58 | public: 59 | MFCC(int num_mfcc_features, int frame_len, int mfcc_dec_bits); 60 | ~MFCC(); 61 | void mfcc_compute(const int16_t* data, q7_t* mfcc_out); 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/analogin_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_ANALOGIN_API_H 20 | #define MBED_ANALOGIN_API_H 21 | 22 | #include "device.h" 23 | 24 | #if DEVICE_ANALOGIN 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** Analogin hal structure. analogin_s is declared in the target's hal 31 | */ 32 | typedef struct analogin_s analogin_t; 33 | 34 | /** 35 | * \defgroup hal_analogin Analogin hal functions 36 | * @{ 37 | */ 38 | 39 | /** Initialize the analogin peripheral 40 | * 41 | * Configures the pin used by analogin. 42 | * @param obj The analogin object to initialize 43 | * @param pin The analogin pin name 44 | */ 45 | void analogin_init(analogin_t *obj, PinName pin); 46 | 47 | /** Read the input voltage, represented as a float in the range [0.0, 1.0] 48 | * 49 | * @param obj The analogin object 50 | * @return A floating value representing the current input voltage 51 | */ 52 | float analogin_read(analogin_t *obj); 53 | 54 | /** Read the value from analogin pin, represented as an unsigned 16bit value 55 | * 56 | * @param obj The analogin object 57 | * @return An unsigned 16bit value representing the current input voltage 58 | */ 59 | uint16_t analogin_read_u16(analogin_t *obj); 60 | 61 | /**@}*/ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | 69 | #endif 70 | 71 | /** @}*/ 72 | -------------------------------------------------------------------------------- /Deployment/Source/KWS_F746NG/kws_f746ng.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "kws_f746ng.h" 20 | 21 | KWS_F746NG::KWS_F746NG(int recording_win, int sliding_window_len) 22 | :KWS_DS_CNN(recording_win, sliding_window_len) 23 | //:KWS_DNN(recording_win, sliding_window_len) 24 | // Change the parent class to KWS_DNN to switch to DNN model 25 | { 26 | audio_buffer = new int16_t[audio_buffer_size]; 27 | audio_buffer_in = new int16_t[audio_block_size*4]; //2 (L/R) channels x 2 for ping-pong buffers 28 | audio_buffer_out = new int16_t[audio_block_size*4]; //2 (L/R) channels x 2 for ping-pong buffers 29 | } 30 | 31 | KWS_F746NG::~KWS_F746NG() 32 | { 33 | delete audio_buffer; 34 | delete audio_buffer_in; 35 | delete audio_buffer_out; 36 | } 37 | 38 | void KWS_F746NG::set_volume(int vol) 39 | { 40 | audio.IN_SetVolume(vol); 41 | } 42 | 43 | void KWS_F746NG::start_kws() 44 | { 45 | // Initialize buffers 46 | memset(audio_buffer_in, 0, audio_block_size*8); 47 | memset(audio_buffer_out, 0, audio_block_size*8); 48 | 49 | // May need to adjust volume to get better accuracy/user-experience 50 | audio.IN_SetVolume(85); 51 | 52 | // Start Recording 53 | audio.IN_Record((uint16_t*)audio_buffer_in, audio_block_size * 4); 54 | 55 | // Start Playback for listening to what is being classified 56 | audio.OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02); 57 | audio.OUT_Play((uint16_t*)audio_buffer_out, audio_block_size * 8); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/crc.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * Filename: crc.h 4 | * 5 | * Description: A header file describing the various CRC standards. 6 | * 7 | * Notes: 8 | * 9 | * 10 | * Copyright (c) 2000 by Michael Barr. This software is placed into 11 | * the public domain and may be used for any purpose. However, this 12 | * notice must not be changed or removed and no warranty is either 13 | * expressed or implied by its publication or distribution. 14 | **********************************************************************/ 15 | 16 | #ifndef _crc_h 17 | #define _crc_h 18 | 19 | 20 | #define FALSE 0 21 | #define TRUE !FALSE 22 | 23 | /* 24 | * Select the CRC standard from the list that follows. 25 | */ 26 | #define CRC16 27 | 28 | 29 | #if defined(CRC_CCITT) 30 | 31 | typedef unsigned short crc; 32 | 33 | #define CRC_NAME "CRC-CCITT" 34 | #define POLYNOMIAL 0x1021 35 | #define INITIAL_REMAINDER 0xFFFF 36 | #define FINAL_XOR_VALUE 0x0000 37 | #define REFLECT_DATA FALSE 38 | #define REFLECT_REMAINDER FALSE 39 | #define CHECK_VALUE 0x29B1 40 | 41 | #elif defined(CRC16) 42 | 43 | typedef unsigned short crc; 44 | 45 | #define CRC_NAME "CRC-16" 46 | #define POLYNOMIAL 0x8005 47 | #define INITIAL_REMAINDER 0x0000 48 | #define FINAL_XOR_VALUE 0x0000 49 | #define REFLECT_DATA TRUE 50 | #define REFLECT_REMAINDER TRUE 51 | #define CHECK_VALUE 0xBB3D 52 | 53 | #elif defined(CRC32) 54 | 55 | typedef unsigned long crc; 56 | 57 | #define CRC_NAME "CRC-32" 58 | #define POLYNOMIAL 0x04C11DB7 59 | #define INITIAL_REMAINDER 0xFFFFFFFF 60 | #define FINAL_XOR_VALUE 0xFFFFFFFF 61 | #define REFLECT_DATA TRUE 62 | #define REFLECT_REMAINDER TRUE 63 | #define CHECK_VALUE 0xCBF43926 64 | 65 | #else 66 | 67 | #error "One of CRC_CCITT, CRC16, or CRC32 must be #define'd." 68 | 69 | #endif 70 | 71 | 72 | void crcInit(void); 73 | crc crcSlow(unsigned char const message[], int nBytes); 74 | crc crcFast(unsigned char const message[], int nBytes); 75 | 76 | 77 | #endif /* _crc_h */ 78 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/SerialWireOutput.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2017 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #if defined(DEVICE_ITM) 18 | 19 | #include "hal/itm_api.h" 20 | #include "platform/FileHandle.h" 21 | 22 | class SerialWireOutput : public FileHandle { 23 | public: 24 | SerialWireOutput(void) 25 | { 26 | /* Initialize ITM using internal init function. */ 27 | mbed_itm_init(); 28 | } 29 | 30 | virtual ssize_t write(const void *buffer, size_t size) 31 | { 32 | const unsigned char *buf = static_cast(buffer); 33 | 34 | /* Send buffer one character at a time over the ITM SWO port */ 35 | for (size_t i = 0; i < size; i++) { 36 | mbed_itm_send(ITM_PORT_SWO, buf[i]); 37 | } 38 | return size; 39 | } 40 | 41 | virtual ssize_t read(void *buffer, size_t size) 42 | { 43 | /* Reading is not supported by this file handle */ 44 | return -EBADF; 45 | } 46 | 47 | virtual off_t seek(off_t offset, int whence = SEEK_SET) 48 | { 49 | /* Seeking is not support by this file handler */ 50 | return -ESPIPE; 51 | } 52 | 53 | virtual off_t size() 54 | { 55 | /* Size is not defined for this file handle */ 56 | return -EINVAL; 57 | } 58 | 59 | virtual int isatty() 60 | { 61 | /* File handle is used for terminal output */ 62 | return true; 63 | } 64 | 65 | virtual int close() 66 | { 67 | return 0; 68 | } 69 | }; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_poll.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2017 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_POLL_H 17 | #define MBED_POLL_H 18 | 19 | #define POLLIN 0x0001 ///< Data may be read without blocking 20 | #define POLLOUT 0x0010 ///< Data may be written without blocking 21 | #define POLLERR 0x1000 ///< An error has occurred on the device or stream 22 | #define POLLHUP 0x2000 ///< The device has been disconnected 23 | #define POLLNVAL 0x4000 ///< The specified file handle value is invalid 24 | 25 | namespace mbed { 26 | 27 | class FileHandle; 28 | 29 | /** \addtogroup platform */ 30 | /** @{*/ 31 | /** 32 | * \defgroup platform_poll poll functions 33 | * @{ 34 | */ 35 | 36 | struct pollfh { 37 | FileHandle *fh; 38 | short events; 39 | short revents; 40 | }; 41 | 42 | /** A mechanism to multiplex input/output over a set of file handles(file descriptors). 43 | * For every file handle provided, poll() examines it for any events registered for that particular 44 | * file handle. 45 | * 46 | * @param fhs an array of PollFh struct carrying a FileHandle and bitmasks of events 47 | * @param nfhs number of file handles 48 | * @param timeout timer value to timeout or -1 for loop forever 49 | * 50 | * @return number of file handles selected (for which revents is non-zero). 0 if timed out with nothing selected. -1 for error. 51 | */ 52 | int poll(pollfh fhs[], unsigned nfhs, int timeout); 53 | 54 | /**@}*/ 55 | 56 | /**@}*/ 57 | 58 | } // namespace mbed 59 | 60 | #endif //MBED_POLL_H 61 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_debug.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup platform */ 3 | /** @{*/ 4 | /** 5 | * \defgroup platform_debug Debug functions 6 | * @{ 7 | */ 8 | 9 | /* mbed Microcontroller Library 10 | * Copyright (c) 2006-2013 ARM Limited 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | #ifndef MBED_DEBUG_H 25 | #define MBED_DEBUG_H 26 | #if DEVICE_STDIO_MESSAGES 27 | #include 28 | #include 29 | #endif 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | 36 | /** Output a debug message 37 | * 38 | * @param format printf-style format string, followed by variables 39 | */ 40 | static inline void debug(const char *format, ...) { 41 | #if DEVICE_STDIO_MESSAGES && !defined(NDEBUG) 42 | va_list args; 43 | va_start(args, format); 44 | vfprintf(stderr, format, args); 45 | va_end(args); 46 | #endif 47 | } 48 | 49 | 50 | /** Conditionally output a debug message 51 | * 52 | * NOTE: If the condition is constant false (== 0) and the compiler optimization 53 | * level is greater than 0, then the whole function will be compiled away. 54 | * 55 | * @param condition output only if condition is true (!= 0) 56 | * @param format printf-style format string, followed by variables 57 | */ 58 | static inline void debug_if(int condition, const char *format, ...) { 59 | #if DEVICE_STDIO_MESSAGES && !defined(NDEBUG) 60 | if (condition) { 61 | va_list args; 62 | va_start(args, format); 63 | vfprintf(stderr, format, args); 64 | va_end(args); 65 | } 66 | #endif 67 | } 68 | 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | 76 | /**@}*/ 77 | 78 | /**@}*/ 79 | 80 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/Driver_Common.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* 5 | * Copyright (c) 2006-2016, ARM Limited, All Rights Reserved 6 | * SPDX-License-Identifier: Apache-2.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 9 | * not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 16 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | #ifndef __DRIVER_COMMON_H 22 | #define __DRIVER_COMMON_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /****** This file has been deprecated since mbed-os-5.5 *****/ 29 | 30 | #define ARM_DRIVER_VERSION_MAJOR_MINOR(major,minor) (((major) << 8) | (minor)) 31 | 32 | /** 33 | \brief Driver Version 34 | */ 35 | typedef struct _ARM_DRIVER_VERSION { 36 | uint16_t api; ///< API version 37 | uint16_t drv; ///< Driver version 38 | } ARM_DRIVER_VERSION; 39 | 40 | /* General return codes */ 41 | #define ARM_DRIVER_OK 0 ///< Operation succeeded 42 | #define ARM_DRIVER_ERROR -1 ///< Unspecified error 43 | #define ARM_DRIVER_ERROR_BUSY -2 ///< Driver is busy 44 | #define ARM_DRIVER_ERROR_TIMEOUT -3 ///< Timeout occurred 45 | #define ARM_DRIVER_ERROR_UNSUPPORTED -4 ///< Operation not supported 46 | #define ARM_DRIVER_ERROR_PARAMETER -5 ///< Parameter error 47 | #define ARM_DRIVER_ERROR_SPECIFIC -6 ///< Start of driver specific errors 48 | 49 | /** 50 | \brief General power states 51 | */ 52 | typedef enum _ARM_POWER_STATE { 53 | ARM_POWER_OFF, ///< Power off: no operation possible 54 | ARM_POWER_LOW, ///< Low Power mode: retain state, detect and signal wake-up events 55 | ARM_POWER_FULL ///< Power on: full operation at maximum performance 56 | } ARM_POWER_STATE; 57 | 58 | #endif /* __DRIVER_COMMON_H */ 59 | 60 | /** @}*/ 61 | -------------------------------------------------------------------------------- /MCU-KWS-explore.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## To explore a pre-trained model\n", 8 | "First run this cell then open a TensorBoard in directory `./logs/DS_CNN/DS_CNN_L`\n", 9 | "\n", 10 | "`tensorboard --logdir=./logs/DS_CNN/DS_CNN_L`" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 7, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "import tensorflow as tf\n", 20 | "from tensorflow.python.platform import gfile\n", 21 | "with tf.Session() as sess:\n", 22 | " model_filename ='Pretrained_models/DS_CNN/DS_CNN_L.pb'\n", 23 | " with gfile.FastGFile(model_filename, 'rb') as f:\n", 24 | " graph_def = tf.GraphDef()\n", 25 | " graph_def.ParseFromString(f.read())\n", 26 | " g_in = tf.import_graph_def(graph_def)\n", 27 | "LOGDIR='./logs/DS_CNN/DS_CNN_L'\n", 28 | "train_writer = tf.summary.FileWriter(LOGDIR)\n", 29 | "train_writer.add_graph(sess.graph)" 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "## To find out the sampling rate of a wav file" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 5, 42 | "metadata": {}, 43 | "outputs": [ 44 | { 45 | "name": "stdout", 46 | "output_type": "stream", 47 | "text": [ 48 | "16000\n" 49 | ] 50 | } 51 | ], 52 | "source": [ 53 | "import os\n", 54 | "import wave\n", 55 | "with wave.open('audio/five_00f0204f_nohash_0.wav', \"rb\") as wave_file:\n", 56 | " frame_rate = wave_file.getframerate()\n", 57 | " print(frame_rate)" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [] 66 | } 67 | ], 68 | "metadata": { 69 | "kernelspec": { 70 | "display_name": "Python 3", 71 | "language": "python", 72 | "name": "python3" 73 | }, 74 | "language_info": { 75 | "codemirror_mode": { 76 | "name": "ipython", 77 | "version": 3 78 | }, 79 | "file_extension": ".py", 80 | "mimetype": "text/x-python", 81 | "name": "python", 82 | "nbconvert_exporter": "python", 83 | "pygments_lexer": "ipython3", 84 | "version": "3.5.2" 85 | } 86 | }, 87 | "nbformat": 4, 88 | "nbformat_minor": 2 89 | } 90 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/Transaction.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_TRANSACTION_H 17 | #define MBED_TRANSACTION_H 18 | 19 | #include "platform/platform.h" 20 | #include "platform/FunctionPointer.h" 21 | 22 | namespace mbed { 23 | /** \addtogroup platform */ 24 | /** @{*/ 25 | /** 26 | * \defgroup platform_Transaction Transaction class 27 | * @{ 28 | */ 29 | 30 | /** Transaction structure 31 | */ 32 | typedef struct { 33 | void *tx_buffer; /**< Tx buffer */ 34 | size_t tx_length; /**< Length of Tx buffer*/ 35 | void *rx_buffer; /**< Rx buffer */ 36 | size_t rx_length; /**< Length of Rx buffer */ 37 | uint32_t event; /**< Event for a transaction */ 38 | event_callback_t callback; /**< User's callback */ 39 | uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */ 40 | } transaction_t; 41 | 42 | /** Transaction class defines a transaction. 43 | * 44 | * @note Synchronization level: Not protected 45 | */ 46 | template 47 | class Transaction { 48 | public: 49 | Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) { 50 | } 51 | 52 | Transaction() : _obj(), _data() { 53 | } 54 | 55 | ~Transaction() { 56 | } 57 | 58 | /** Get object's instance for the transaction 59 | * 60 | * @return The object which was stored 61 | */ 62 | Class* get_object() { 63 | return _obj; 64 | } 65 | 66 | /** Get the transaction 67 | * 68 | * @return The transaction which was stored 69 | */ 70 | transaction_t* get_transaction() { 71 | return &_data; 72 | } 73 | 74 | private: 75 | Class* _obj; 76 | transaction_t _data; 77 | }; 78 | /**@}*/ 79 | 80 | /**@}*/ 81 | } 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_error.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup platform */ 3 | /** @{*/ 4 | /** 5 | * \defgroup platform_error Error functions 6 | * @{ 7 | */ 8 | /* mbed Microcontroller Library 9 | * Copyright (c) 2006-2013 ARM Limited 10 | * 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 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | #ifndef MBED_ERROR_H 24 | #define MBED_ERROR_H 25 | 26 | 27 | 28 | /** To generate a fatal compile-time error, you can use the pre-processor #error directive. 29 | * 30 | * @param format C string that contains data stream to be printed. 31 | * Code snippets below show valid format. 32 | * 33 | * @code 34 | * #error "That shouldn't have happened!" 35 | * @endcode 36 | * 37 | * If the compiler evaluates this line, it will report the error and stop the compile. 38 | * 39 | * For example, you could use this to check some user-defined compile-time variables: 40 | * 41 | * @code 42 | * #define NUM_PORTS 7 43 | * #if (NUM_PORTS > 4) 44 | * #error "NUM_PORTS must be less than 4" 45 | * #endif 46 | * @endcode 47 | * 48 | * Reporting Run-Time Errors: 49 | * To generate a fatal run-time error, you can use the mbed error() function. 50 | * 51 | * @code 52 | * error("That shouldn't have happened!"); 53 | * @endcode 54 | * 55 | * If the mbed running the program executes this function, it will print the 56 | * message via the USB serial port, and then die with the blue lights of death! 57 | * 58 | * The message can use printf-style formatting, so you can report variables in the 59 | * message too. For example, you could use this to check a run-time condition: 60 | * 61 | * @code 62 | * if(x >= 5) { 63 | * error("expected x to be less than 5, but got %d", x); 64 | * } 65 | * @endcode 66 | * 67 | * 68 | */ 69 | 70 | #ifdef __cplusplus 71 | extern "C" { 72 | #endif 73 | void error(const char* format, ...); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif 80 | 81 | /** @}*/ 82 | /** @}*/ 83 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/cmsis_nvic.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | ******************************************************************************* 3 | * Copyright (c) 2011 ARM Limited. All rights reserved. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 3. Neither the name of ARM Limited nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ******************************************************************************* 29 | */ 30 | 31 | #ifndef MBED_CMSIS_NVIC_H 32 | #define MBED_CMSIS_NVIC_H 33 | 34 | #if defined(__CC_ARM) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) 35 | extern uint32_t Image$$VECTOR_RAM$$Base[]; 36 | #define __VECTOR_RAM Image$$VECTOR_RAM$$Base 37 | #else 38 | extern uint32_t __VECTOR_RAM[]; 39 | #endif /* defined(__CC_ARM) */ 40 | 41 | /* Symbols defined by the linker script */ 42 | #define NVIC_NUM_VECTORS (16 + 86) // CORE + MCU Peripherals 43 | #define NVIC_RAM_VECTOR_ADDRESS (__VECTOR_RAM) // Vectors positioned at start of RAM 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/itm_api.h: -------------------------------------------------------------------------------- 1 | /** \addtogroup hal */ 2 | /** @{*/ 3 | /* mbed Microcontroller Library 4 | * Copyright (c) 2017 ARM Limited 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef MBED_ITM_API_H 20 | #define MBED_ITM_API_H 21 | 22 | #if defined(DEVICE_ITM) 23 | 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** 31 | * \defgroup itm_hal Instrumented Trace Macrocell HAL API 32 | * @{ 33 | */ 34 | 35 | enum { 36 | ITM_PORT_SWO = 0 37 | }; 38 | 39 | /** 40 | * @brief Target specific initialization function. 41 | * This function is responsible for initializing and configuring 42 | * the debug clock for the ITM and setting up the SWO pin for 43 | * debug output. 44 | * 45 | * The only Cortex-M register that should be modified is the clock 46 | * prescaler in TPI->ACPR. 47 | * 48 | * The generic mbed_itm_init initialization function will setup: 49 | * 50 | * ITM->LAR 51 | * ITM->TPR 52 | * ITM->TCR 53 | * ITM->TER 54 | * TPI->SPPR 55 | * TPI->FFCR 56 | * DWT->CTRL 57 | * 58 | * for SWO output on stimulus port 0. 59 | */ 60 | void itm_init(void); 61 | 62 | /** 63 | * @brief Initialization function for both generic registers and target specific clock and pin. 64 | */ 65 | void mbed_itm_init(void); 66 | 67 | /** 68 | * @brief Send data over ITM stimulus port. 69 | * 70 | * @param[in] port The stimulus port to send data over. 71 | * @param[in] data The data to send. 72 | * 73 | * @return value of data sent. 74 | */ 75 | uint32_t mbed_itm_send(uint32_t port, uint32_t data); 76 | 77 | /**@}*/ 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif 84 | 85 | #endif /* MBED_ITM_API_H */ 86 | 87 | /**@}*/ 88 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/fsl_clock_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef _CLOCK_CONFIG_H_ 31 | #define _CLOCK_CONFIG_H_ 32 | 33 | /******************************************************************************* 34 | * DEFINITION 35 | ******************************************************************************/ 36 | #define BOARD_XTAL0_CLK_HZ 50000000U 37 | #define BOARD_XTAL32K_CLK_HZ 32768U 38 | 39 | /******************************************************************************* 40 | * API 41 | ******************************************************************************/ 42 | #if defined(__cplusplus) 43 | extern "C" { 44 | #endif /* __cplusplus*/ 45 | 46 | void BOARD_BootClockVLPR(void); 47 | void BOARD_BootClockRUN(void); 48 | 49 | #if defined(__cplusplus) 50 | } 51 | #endif /* __cplusplus*/ 52 | 53 | #endif /* _CLOCK_CONFIG_H_ */ 54 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/dma_api_hal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef MBED_DMA_API_HAL_H 32 | #define MBED_DMA_API_HAL_H 33 | 34 | #include "dma_api.h" 35 | #if defined(FSL_FEATURE_SOC_EDMA_COUNT) && (FSL_FEATURE_SOC_EDMA_COUNT >= 1U) 36 | #include "fsl_edma.h" 37 | #endif 38 | #if defined(FSL_FEATURE_SOC_DMA_COUNT) && (FSL_FEATURE_SOC_DMA_COUNT >= 1U) 39 | #include "fsl_dma.h" 40 | #endif 41 | 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | typedef struct { 48 | DMAUsage dmaUsageState; 49 | int dmaChannel; 50 | #if defined(FSL_FEATURE_SOC_EDMA_COUNT) && (FSL_FEATURE_SOC_EDMA_COUNT >= 1U) 51 | edma_handle_t handle; 52 | #endif 53 | #if defined(FSL_FEATURE_SOC_DMA_COUNT) && (FSL_FEATURE_SOC_DMA_COUNT >= 1U) 54 | dma_handle_t handle; 55 | #endif 56 | } dma_options_t; 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/sleep_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_SLEEP_API_H 20 | #define MBED_SLEEP_API_H 21 | 22 | #include "device.h" 23 | 24 | #if DEVICE_SLEEP 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** Send the microcontroller to sleep 31 | * 32 | * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the 33 | * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates 34 | * dynamic power used by the processor, memory systems and buses. The processor, peripheral and 35 | * memory state are maintained, and the peripherals continue to work and can generate interrupts. 36 | * 37 | * The processor can be woken up by any internal peripheral interrupt or external pin interrupt. 38 | * 39 | * @note 40 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. 41 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be 42 | * able to access the LocalFileSystem 43 | */ 44 | void hal_sleep(void); 45 | 46 | /** Send the microcontroller to deep sleep 47 | * 48 | * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode 49 | * has the same sleep features as sleep plus it powers down peripherals and clocks. All state 50 | * is still maintained. 51 | * 52 | * The processor can only be woken up by an external interrupt on a pin or a watchdog timer. 53 | * 54 | * @note 55 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. 56 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be 57 | * able to access the LocalFileSystem 58 | */ 59 | void hal_deepsleep(void); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | 67 | #endif 68 | 69 | /** @}*/ 70 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/can_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2016 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_CAN_API_H 20 | #define MBED_CAN_API_H 21 | 22 | #include "device.h" 23 | 24 | #if DEVICE_CAN 25 | 26 | #include "PinNames.h" 27 | #include "PeripheralNames.h" 28 | #include "hal/can_helper.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | typedef enum { 35 | IRQ_RX, 36 | IRQ_TX, 37 | IRQ_ERROR, 38 | IRQ_OVERRUN, 39 | IRQ_WAKEUP, 40 | IRQ_PASSIVE, 41 | IRQ_ARB, 42 | IRQ_BUS, 43 | IRQ_READY 44 | } CanIrqType; 45 | 46 | 47 | typedef enum { 48 | MODE_RESET, 49 | MODE_NORMAL, 50 | MODE_SILENT, 51 | MODE_TEST_LOCAL, 52 | MODE_TEST_GLOBAL, 53 | MODE_TEST_SILENT 54 | } CanMode; 55 | 56 | typedef void (*can_irq_handler)(uint32_t id, CanIrqType type); 57 | 58 | typedef struct can_s can_t; 59 | 60 | void can_init (can_t *obj, PinName rd, PinName td); 61 | void can_init_freq (can_t *obj, PinName rd, PinName td, int hz); 62 | void can_free (can_t *obj); 63 | int can_frequency (can_t *obj, int hz); 64 | 65 | void can_irq_init (can_t *obj, can_irq_handler handler, uint32_t id); 66 | void can_irq_free (can_t *obj); 67 | void can_irq_set (can_t *obj, CanIrqType irq, uint32_t enable); 68 | 69 | int can_write (can_t *obj, CAN_Message, int cc); 70 | int can_read (can_t *obj, CAN_Message *msg, int handle); 71 | int can_mode (can_t *obj, CanMode mode); 72 | int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle); 73 | void can_reset (can_t *obj); 74 | unsigned char can_rderror (can_t *obj); 75 | unsigned char can_tderror (can_t *obj); 76 | void can_monitor (can_t *obj, int silent); 77 | 78 | #ifdef __cplusplus 79 | }; 80 | #endif 81 | 82 | #endif // MBED_CAN_API_H 83 | 84 | #endif 85 | 86 | /** @}*/ 87 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/ScopedLock.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2018 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_SCOPEDLOCK_H 17 | #define MBED_SCOPEDLOCK_H 18 | 19 | #include "platform/NonCopyable.h" 20 | 21 | namespace mbed { 22 | 23 | /** \addtogroup platform */ 24 | /** @{*/ 25 | /** 26 | * \defgroup platform_ScopedLock ScopedLock functions 27 | * @{ 28 | */ 29 | 30 | /** RAII-style mechanism for owning a lock of Lockable object for the duration of a scoped block 31 | * 32 | * @tparam Lockable The type implementing BasicLockable concept 33 | * 34 | * @note For type Lockable to be BasicLockable, the following conditions have to be satisfied: 35 | * - has public member function @a lock which blocks until a lock can be obtained for the current execution context 36 | * - has public member function @a unlock which releases the lock 37 | * 38 | * Usage: 39 | * 40 | * Example with rtos::Mutex 41 | * 42 | * @code 43 | * void foo(Mutex &m) { 44 | * ScopedLock lock(m); 45 | * // Mutex lock protects code in this block 46 | * } 47 | * @endcode 48 | * 49 | * 50 | * More generic example 51 | * 52 | * @code 53 | * template 54 | * void foo(Lockable& lockable) { 55 | * ScopedLock lock(lockable); 56 | * // Code in this block runs under lock 57 | * } 58 | * @endcode 59 | */ 60 | template 61 | class ScopedLock : private NonCopyable > { 62 | public: 63 | /** Locks given locable object 64 | * 65 | * @param lockable reference to the instance of Lockable object 66 | * @note lockable object should outlive the ScopedLock object 67 | */ 68 | ScopedLock(Lockable& lockable): _lockable(lockable) 69 | { 70 | _lockable.lock(); 71 | } 72 | 73 | ~ScopedLock() 74 | { 75 | _lockable.unlock(); 76 | } 77 | private: 78 | Lockable& _lockable; 79 | }; 80 | 81 | /**@}*/ 82 | 83 | /**@}*/ 84 | 85 | } // embed 86 | 87 | #endif // MBED_SCOPEDLOCK_H 88 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/port_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_PORTMAP_H 20 | #define MBED_PORTMAP_H 21 | 22 | #include "device.h" 23 | 24 | #if DEVICE_PORTIN || DEVICE_PORTOUT 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** Port HAL structure. port_s is declared in the target's HAL 31 | */ 32 | typedef struct port_s port_t; 33 | 34 | /** 35 | * \defgroup hal_port Port HAL functions 36 | * @{ 37 | */ 38 | 39 | /** Get the pin name from the port's pin number 40 | * 41 | * @param port The port name 42 | * @param pin_n The pin number within the specified port 43 | * @return The pin name for the port's pin number 44 | */ 45 | PinName port_pin(PortName port, int pin_n); 46 | 47 | /** Initilize the port 48 | * 49 | * @param obj The port object to initialize 50 | * @param port The port name 51 | * @param mask The bitmask to identify which bits in the port should be included (0 - ignore) 52 | * @param dir The port direction 53 | */ 54 | void port_init(port_t *obj, PortName port, int mask, PinDirection dir); 55 | 56 | /** Set the input port mode 57 | * 58 | * @param obj The port object 59 | * @param mode THe port mode to be set 60 | */ 61 | void port_mode(port_t *obj, PinMode mode); 62 | 63 | /** Set port direction (in/out) 64 | * 65 | * @param obj The port object 66 | * @param dir The port direction to be set 67 | */ 68 | void port_dir(port_t *obj, PinDirection dir); 69 | 70 | /** Write value to the port 71 | * 72 | * @param obj The port object 73 | * @param value The value to be set 74 | */ 75 | void port_write(port_t *obj, int value); 76 | 77 | /** Read the current value on the port 78 | * 79 | * @param obj The port object 80 | * @return An integer with each bit corresponding to an associated port pin setting 81 | */ 82 | int port_read(port_t *obj); 83 | 84 | /**@}*/ 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #endif 90 | 91 | #endif 92 | 93 | /** @}*/ 94 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_preprocessor.h: -------------------------------------------------------------------------------- 1 | /** \addtogroup platform */ 2 | /** @{*/ 3 | /** 4 | * \defgroup platform_preprocessor preprocessor macros 5 | * @{ 6 | */ 7 | 8 | /* mbed Microcontroller Library 9 | * Copyright (c) 2006-2013 ARM Limited 10 | * 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 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | #ifndef MBED_PREPROCESSOR_H 24 | #define MBED_PREPROCESSOR_H 25 | 26 | 27 | /** MBED_CONCAT 28 | * Concatenate tokens together 29 | * 30 | * @note 31 | * Expands tokens before concatenation 32 | * 33 | * @code 34 | * // Creates a unique label based on the line number 35 | * int MBED_CONCAT(UNIQUE_LABEL_, __LINE__) = 1; 36 | * @endcode 37 | */ 38 | #define MBED_CONCAT(a, b) MBED_CONCAT_(a, b) 39 | #define MBED_CONCAT_(a, b) a##b 40 | 41 | /** MBED_STRINGIFY 42 | * Converts tokens into strings 43 | * 44 | * @note 45 | * Expands tokens before stringification 46 | * 47 | * @code 48 | * // Creates a string based on the parameters 49 | * const char *c = MBED_STRINGIFY(This is a ridiculous way to create a string) 50 | * @endcode 51 | */ 52 | #define MBED_STRINGIFY(a) MBED_STRINGIFY_(a) 53 | #define MBED_STRINGIFY_(a) #a 54 | 55 | /** MBED_STRLEN 56 | * Reports string token length 57 | * 58 | * @note 59 | * Expands tokens before calculating length 60 | * 61 | * @code 62 | * // Get string length 63 | * const int len = MBED_STRLEN("Get the length") 64 | * @endcode 65 | */ 66 | #define MBED_STRLEN(a) MBED_STRLEN_(a) 67 | #define MBED_STRLEN_(a) (sizeof(a) - 1) 68 | 69 | /** MBED_COUNT_VA_ARGS(...) 70 | * Reports number of tokens passed 71 | * 72 | * @note 73 | * Token limit is 16 74 | * 75 | * @code 76 | * // Get number of arguments 77 | * const int count = MBED_COUNT_VA_ARGS("Address 0x%x, Data[0] = %d Data[1] = %d", 0x20001234, 10, 20) 78 | * @endcode 79 | */ 80 | #define MBED_COUNT_VA_ARGS(...) GET_NTH_ARG_(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1) 81 | #define GET_NTH_ARG_(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, N, ...) N 82 | 83 | #endif 84 | 85 | /** @}*/ 86 | /** @}*/ 87 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/objects.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_OBJECTS_H 17 | #define MBED_OBJECTS_H 18 | 19 | #include "cmsis.h" 20 | #include "PortNames.h" 21 | #include "PeripheralNames.h" 22 | #include "PinNames.h" 23 | #if DEVICE_SPI_ASYNCH 24 | #include "fsl_dspi_edma.h" 25 | #endif 26 | #if DEVICE_SERIAL_ASYNCH 27 | #include "fsl_uart_edma.h" 28 | #endif 29 | #include "fsl_flash.h" 30 | #include "dma_api_hal.h" 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | struct gpio_irq_s { 37 | uint32_t port; 38 | uint32_t pin; 39 | uint32_t ch; 40 | }; 41 | 42 | struct port_s { 43 | PortName port; 44 | uint32_t mask; 45 | }; 46 | 47 | struct pwmout_s { 48 | PWMName pwm_name; 49 | }; 50 | 51 | struct serial_s { 52 | int index; 53 | #if DEVICE_SERIAL_ASYNCH 54 | uint8_t txstate; 55 | uint8_t rxstate; 56 | uint32_t events; 57 | uart_handle_t uart_transfer_handle; 58 | uart_edma_handle_t uart_dma_handle; 59 | dma_options_t uartDmaTx; 60 | dma_options_t uartDmaRx; 61 | #endif 62 | }; 63 | 64 | struct analogin_s { 65 | ADCName adc; 66 | }; 67 | 68 | struct i2c_s { 69 | uint32_t instance; 70 | uint8_t next_repeated_start; 71 | }; 72 | 73 | struct spi_s { 74 | uint32_t instance; 75 | uint8_t bits; 76 | #if DEVICE_SPI_ASYNCH 77 | status_t status; 78 | dspi_master_handle_t spi_master_handle; 79 | dspi_master_edma_handle_t spi_dma_master_handle; 80 | dma_options_t spiDmaMasterRx; 81 | dma_options_t spiDmaMasterTx; 82 | dma_options_t spiDmaMasterIntermediary; 83 | #endif 84 | }; 85 | 86 | struct dac_s { 87 | DACName dac; 88 | }; 89 | 90 | struct trng_s { 91 | uint8_t dummy; 92 | }; 93 | 94 | struct flash_s { 95 | flash_config_t flash_config; 96 | }; 97 | 98 | #include "gpio_object.h" 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /Deployment/Source/NN/DNN/dnn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __DNN_H__ 20 | #define __DNN_H__ 21 | 22 | #include "nn.h" 23 | #include "dnn_weights.h" 24 | #include "arm_nnfunctions.h" 25 | #include "arm_math.h" 26 | 27 | /* Network Structure 28 | 29 | 10x25 input features 30 | | 31 | IP1 : Innerproduct (weights: 250x144) 32 | | 33 | IP2 : Innerproduct (weights: 144x144) 34 | | 35 | IP3 : Innerproduct (weights: 144x144) 36 | | 37 | IP4 : Innerproduct (weights: 144x12) 38 | | 39 | 12 outputs 40 | 41 | */ 42 | 43 | #define SAMP_FREQ 16000 44 | #define MFCC_DEC_BITS 2 45 | #define FRAME_SHIFT_MS 40 46 | #define FRAME_SHIFT ((int16_t)(SAMP_FREQ * 0.001 * FRAME_SHIFT_MS)) 47 | #define NUM_FRAMES 25 48 | #define NUM_MFCC_COEFFS 10 49 | #define MFCC_BUFFER_SIZE (NUM_FRAMES*NUM_MFCC_COEFFS) 50 | #define FRAME_LEN_MS 40 51 | #define FRAME_LEN ((int16_t)(SAMP_FREQ * 0.001 * FRAME_LEN_MS)) 52 | 53 | #define IN_DIM (NUM_FRAMES*NUM_MFCC_COEFFS) 54 | #define OUT_DIM 12 55 | #define IP1_OUT_DIM 144 56 | #define IP2_OUT_DIM 144 57 | #define IP3_OUT_DIM 144 58 | #define IP1_WT_DIM (IP1_OUT_DIM*IN_DIM) 59 | #define IP2_WT_DIM (IP2_OUT_DIM*IP1_OUT_DIM) 60 | #define IP3_WT_DIM (IP3_OUT_DIM*IP2_OUT_DIM) 61 | #define IP4_WT_DIM (OUT_DIM*IP3_OUT_DIM) 62 | #define SCRATCH_BUFFER_SIZE (2*(IN_DIM+3*IP1_OUT_DIM)) 63 | 64 | class DNN : public NN { 65 | 66 | public: 67 | DNN(); 68 | ~DNN(); 69 | void run_nn(q7_t* in_data, q7_t* out_data); 70 | 71 | private: 72 | q7_t* scratch_pad; 73 | q7_t* ip1_out; 74 | q7_t* ip2_out; 75 | q7_t* ip3_out; 76 | q15_t* vec_buffer; 77 | static q7_t const ip1_wt[IP1_WT_DIM]; 78 | static q7_t const ip1_bias[IP1_OUT_DIM]; 79 | static q7_t const ip2_wt[IP2_WT_DIM]; 80 | static q7_t const ip2_bias[IP2_OUT_DIM]; 81 | static q7_t const ip3_wt[IP3_WT_DIM]; 82 | static q7_t const ip3_bias[IP3_OUT_DIM]; 83 | static q7_t const ip4_wt[IP4_WT_DIM]; 84 | static q7_t const ip4_bias[OUT_DIM]; 85 | 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/gpio_irq_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_GPIO_IRQ_API_H 20 | #define MBED_GPIO_IRQ_API_H 21 | 22 | #include "device.h" 23 | 24 | #if DEVICE_INTERRUPTIN 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** GPIO IRQ events 31 | */ 32 | typedef enum { 33 | IRQ_NONE, 34 | IRQ_RISE, 35 | IRQ_FALL 36 | } gpio_irq_event; 37 | 38 | /** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL 39 | */ 40 | typedef struct gpio_irq_s gpio_irq_t; 41 | 42 | typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event); 43 | 44 | /** 45 | * \defgroup hal_gpioirq GPIO IRQ HAL functions 46 | * @{ 47 | */ 48 | 49 | /** Initialize the GPIO IRQ pin 50 | * 51 | * @param obj The GPIO object to initialize 52 | * @param pin The GPIO pin name 53 | * @param handler The handler to be attached to GPIO IRQ 54 | * @param id The object ID (id != 0, 0 is reserved) 55 | * @return -1 if pin is NC, 0 otherwise 56 | */ 57 | int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id); 58 | 59 | /** Release the GPIO IRQ PIN 60 | * 61 | * @param obj The gpio object 62 | */ 63 | void gpio_irq_free(gpio_irq_t *obj); 64 | 65 | /** Enable/disable pin IRQ event 66 | * 67 | * @param obj The GPIO object 68 | * @param event The GPIO IRQ event 69 | * @param enable The enable flag 70 | */ 71 | void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable); 72 | 73 | /** Enable GPIO IRQ 74 | * 75 | * This is target dependent, as it might enable the entire port or just a pin 76 | * @param obj The GPIO object 77 | */ 78 | void gpio_irq_enable(gpio_irq_t *obj); 79 | 80 | /** Disable GPIO IRQ 81 | * 82 | * This is target dependent, as it might disable the entire port or just a pin 83 | * @param obj The GPIO object 84 | */ 85 | void gpio_irq_disable(gpio_irq_t *obj); 86 | 87 | /**@}*/ 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif 94 | 95 | #endif 96 | 97 | /** @}*/ 98 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/DeepSleepLock.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2017 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_DEEPSLEEPLOCK_H 17 | #define MBED_DEEPSLEEPLOCK_H 18 | 19 | #include 20 | #include "platform/mbed_power_mgmt.h" 21 | #include "platform/mbed_critical.h" 22 | 23 | namespace mbed { 24 | 25 | /** \addtogroup platform */ 26 | /** @{*/ 27 | /** 28 | * \defgroup platform_DeepSleepLock DeepSleepLock functions 29 | * @{ 30 | */ 31 | 32 | /** RAII object for disabling, then restoring the deep sleep mode 33 | * Usage: 34 | * @code 35 | * 36 | * void f() { 37 | * // some code here 38 | * { 39 | * DeepSleepLock lock; 40 | * // Code in this block will run with the deep sleep mode locked 41 | * } 42 | * // deep sleep mode will be restored to their previous state 43 | * } 44 | * @endcode 45 | */ 46 | class DeepSleepLock { 47 | private: 48 | uint16_t _lock_count; 49 | 50 | public: 51 | DeepSleepLock(): _lock_count(1) 52 | { 53 | sleep_manager_lock_deep_sleep(); 54 | } 55 | 56 | ~DeepSleepLock() 57 | { 58 | if (_lock_count) { 59 | sleep_manager_unlock_deep_sleep(); 60 | } 61 | } 62 | 63 | /** Mark the start of a locked deep sleep section 64 | */ 65 | void lock() 66 | { 67 | uint16_t count = core_util_atomic_incr_u16(&_lock_count, 1); 68 | if (1 == count) { 69 | sleep_manager_lock_deep_sleep(); 70 | } 71 | if (0 == count) { 72 | error("DeepSleepLock overflow (> USHRT_MAX)"); 73 | } 74 | } 75 | 76 | /** Mark the end of a locked deep sleep section 77 | */ 78 | void unlock() 79 | { 80 | uint16_t count = core_util_atomic_decr_u16(&_lock_count, 1); 81 | if (count == 0) { 82 | sleep_manager_unlock_deep_sleep(); 83 | } 84 | if (count == USHRT_MAX) { 85 | core_util_critical_section_exit(); 86 | error("DeepSleepLock underflow (< 0)"); 87 | } 88 | } 89 | }; 90 | 91 | /**@}*/ 92 | 93 | /**@}*/ 94 | 95 | 96 | } 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/analogout_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2013 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_ANALOGOUT_API_H 20 | #define MBED_ANALOGOUT_API_H 21 | 22 | #include "device.h" 23 | 24 | #if DEVICE_ANALOGOUT 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** Analogout hal structure. dac_s is declared in the target's hal 31 | */ 32 | typedef struct dac_s dac_t; 33 | 34 | /** 35 | * \defgroup hal_analogout Analogout hal functions 36 | * @{ 37 | */ 38 | 39 | /** Initialize the analogout peripheral 40 | * 41 | * Configures the pin used by analogout. 42 | * @param obj The analogout object to initialize 43 | * @param pin The analogout pin name 44 | */ 45 | void analogout_init(dac_t *obj, PinName pin); 46 | 47 | /** Release the analogout object 48 | * 49 | * Note: This is not currently used in the mbed-drivers 50 | * @param obj The analogout object 51 | */ 52 | void analogout_free(dac_t *obj); 53 | 54 | /** Set the output voltage, specified as a percentage (float) 55 | * 56 | * @param obj The analogin object 57 | * @param value The floating-point output voltage to be set 58 | */ 59 | void analogout_write(dac_t *obj, float value); 60 | 61 | /** Set the output voltage, specified as unsigned 16-bit 62 | * 63 | * @param obj The analogin object 64 | * @param value The unsigned 16-bit output voltage to be set 65 | */ 66 | void analogout_write_u16(dac_t *obj, uint16_t value); 67 | 68 | /** Read the current voltage value on the pin 69 | * 70 | * @param obj The analogin object 71 | * @return A floating-point value representing the current voltage on the pin, 72 | * measured as a percentage 73 | */ 74 | float analogout_read(dac_t *obj); 75 | 76 | /** Read the current voltage value on the pin, as a normalized unsigned 16bit value 77 | * 78 | * @param obj The analogin object 79 | * @return An unsigned 16-bit value representing the current voltage on the pin 80 | */ 81 | uint16_t analogout_read_u16(dac_t *obj); 82 | 83 | /**@}*/ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif 90 | 91 | #endif 92 | 93 | /** @}*/ 94 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/Stream.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_STREAM_H 17 | #define MBED_STREAM_H 18 | 19 | #include "platform/platform.h" 20 | #include "platform/FileLike.h" 21 | #include "platform/FileHandle.h" 22 | #include "platform/NonCopyable.h" 23 | #include 24 | #include 25 | 26 | namespace mbed { 27 | /** \addtogroup platform */ 28 | /** @{*/ 29 | /** 30 | * \defgroup platform_Stream Stream class 31 | * @{ 32 | */ 33 | 34 | extern void mbed_set_unbuffered_stream(std::FILE *_file); 35 | extern int mbed_getc(std::FILE *_file); 36 | extern char* mbed_gets(char *s, int size, std::FILE *_file); 37 | 38 | /** File stream 39 | * 40 | * @note Synchronization level: Set by subclass 41 | */ 42 | class Stream : public FileLike, private NonCopyable { 43 | 44 | public: 45 | Stream(const char *name=NULL); 46 | virtual ~Stream(); 47 | 48 | int putc(int c); 49 | int puts(const char *s); 50 | int getc(); 51 | char *gets(char *s, int size); 52 | int printf(const char* format, ...); 53 | int scanf(const char* format, ...); 54 | int vprintf(const char* format, std::va_list args); 55 | int vscanf(const char* format, std::va_list args); 56 | 57 | operator std::FILE*() {return _file;} 58 | 59 | protected: 60 | virtual int close(); 61 | virtual ssize_t write(const void* buffer, size_t length); 62 | virtual ssize_t read(void* buffer, size_t length); 63 | virtual off_t seek(off_t offset, int whence); 64 | virtual off_t tell(); 65 | virtual void rewind(); 66 | virtual int isatty(); 67 | virtual int sync(); 68 | virtual off_t size(); 69 | 70 | virtual int _putc(int c) = 0; 71 | virtual int _getc() = 0; 72 | 73 | std::FILE *_file; 74 | 75 | /** Acquire exclusive access to this object. 76 | */ 77 | virtual void lock() { 78 | // Stub 79 | } 80 | 81 | /** Release exclusive access to this object. 82 | */ 83 | virtual void unlock() { 84 | // Stub 85 | } 86 | }; 87 | /**@}*/ 88 | 89 | /**@}*/ 90 | } // namespace mbed 91 | 92 | #endif 93 | 94 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/TimerEvent.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_TIMEREVENT_H 17 | #define MBED_TIMEREVENT_H 18 | 19 | #include "hal/ticker_api.h" 20 | #include "hal/us_ticker_api.h" 21 | #include "platform/NonCopyable.h" 22 | 23 | namespace mbed { 24 | /** \addtogroup drivers */ 25 | 26 | /** Base abstraction for timer interrupts 27 | * 28 | * @note Synchronization level: Interrupt safe 29 | * @ingroup drivers 30 | */ 31 | class TimerEvent : private NonCopyable { 32 | public: 33 | TimerEvent(); 34 | TimerEvent(const ticker_data_t *data); 35 | 36 | /** The handler registered with the underlying timer interrupt 37 | * 38 | * @param id Timer Event ID 39 | */ 40 | static void irq(uint32_t id); 41 | 42 | /** Destruction removes it... 43 | */ 44 | virtual ~TimerEvent(); 45 | 46 | protected: 47 | // The handler called to service the timer event of the derived class 48 | virtual void handler() = 0; 49 | 50 | /** Set relative timestamp of the internal event. 51 | * @param timestamp event's us timestamp 52 | * 53 | * @warning 54 | * Do not insert more than one timestamp. 55 | * The same @a event object is used for every @a insert/insert_absolute call. 56 | * 57 | * @warning 58 | * Ticker's present timestamp is used for reference. For timestamps 59 | * from the past the event is scheduled after ticker's overflow. 60 | * For reference @see convert_timestamp 61 | */ 62 | void insert(timestamp_t timestamp); 63 | 64 | /** Set absolute timestamp of the internal event. 65 | * @param timestamp event's us timestamp 66 | * 67 | * @warning 68 | * Do not insert more than one timestamp. 69 | * The same @a event object is used for every @a insert/insert_absolute call. 70 | */ 71 | void insert_absolute(us_timestamp_t timestamp); 72 | 73 | /** Remove timestamp. 74 | */ 75 | void remove(); 76 | 77 | ticker_event_t event; 78 | 79 | const ticker_data_t *_ticker_data; 80 | }; 81 | 82 | } // namespace mbed 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/peripheral_clock_defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _FSL_PERIPHERAL_CLOCK_H_ 32 | #define _FSL_PERIPHERAL_CLOCK_H_ 33 | 34 | #include "fsl_clock.h" 35 | 36 | /* Array for UART module clocks */ 37 | #define UART_CLOCK_FREQS \ 38 | { \ 39 | UART0_CLK_SRC, UART1_CLK_SRC, UART2_CLK_SRC, UART3_CLK_SRC, UART4_CLK_SRC, UART5_CLK_SRC \ 40 | } 41 | 42 | /* Array for I2C module clocks */ 43 | #define I2C_CLOCK_FREQS \ 44 | { \ 45 | I2C0_CLK_SRC, I2C1_CLK_SRC, I2C2_CLK_SRC \ 46 | } 47 | 48 | /* Array for DSPI module clocks */ 49 | #define SPI_CLOCK_FREQS \ 50 | { \ 51 | DSPI0_CLK_SRC, DSPI1_CLK_SRC, DSPI2_CLK_SRC \ 52 | } 53 | 54 | #endif /* _FSL_PERIPHERAL_CLOCK_H_ */ 55 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/fsl_device_registers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 - 2016, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef __FSL_DEVICE_REGISTERS_H__ 32 | #define __FSL_DEVICE_REGISTERS_H__ 33 | 34 | /* 35 | * Include the cpu specific register header files. 36 | * 37 | * The CPU macro should be declared in the project or makefile. 38 | */ 39 | #if (defined(CPU_MK64FN1M0CAJ12) || defined(CPU_MK64FN1M0VDC12) || defined(CPU_MK64FN1M0VLL12) || \ 40 | defined(CPU_MK64FN1M0VLQ12) || defined(CPU_MK64FN1M0VMD12) || defined(CPU_MK64FX512VDC12) || \ 41 | defined(CPU_MK64FX512VLL12) || defined(CPU_MK64FX512VLQ12) || defined(CPU_MK64FX512VMD12)) 42 | 43 | #define K64F12_SERIES 44 | 45 | /* CMSIS-style register definitions */ 46 | #include "MK64F12.h" 47 | /* CPU specific feature definitions */ 48 | #include "MK64F12_features.h" 49 | 50 | #else 51 | #error "No valid CPU defined!" 52 | #endif 53 | 54 | #endif /* __FSL_DEVICE_REGISTERS_H__ */ 55 | 56 | /******************************************************************************* 57 | * EOF 58 | ******************************************************************************/ 59 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/tz_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016 ARM Limited. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | * 18 | * ---------------------------------------------------------------------------- 19 | * 20 | * $Date: 21. September 2016 21 | * $Revision: V1.0 22 | * 23 | * Project: TrustZone for ARMv8-M 24 | * Title: Context Management for ARMv8-M TrustZone 25 | * 26 | * Version 1.0 27 | * Initial Release 28 | *---------------------------------------------------------------------------*/ 29 | 30 | #ifndef TZ_CONTEXT_H 31 | #define TZ_CONTEXT_H 32 | 33 | #include 34 | 35 | #ifndef TZ_MODULEID_T 36 | #define TZ_MODULEID_T 37 | /// \details Data type that identifies secure software modules called by a process. 38 | typedef uint32_t TZ_ModuleId_t; 39 | #endif 40 | 41 | /// \details TZ Memory ID identifies an allocated memory slot. 42 | typedef uint32_t TZ_MemoryId_t; 43 | 44 | /// Initialize secure context memory system 45 | /// \return execution status (1: success, 0: error) 46 | uint32_t TZ_InitContextSystem_S (void); 47 | 48 | /// Allocate context memory for calling secure software modules in TrustZone 49 | /// \param[in] module identifies software modules called from non-secure mode 50 | /// \return value != 0 id TrustZone memory slot identifier 51 | /// \return value 0 no memory available or internal error 52 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 53 | 54 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 55 | /// \param[in] id TrustZone memory slot identifier 56 | /// \return execution status (1: success, 0: error) 57 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 58 | 59 | /// Load secure context (called on RTOS thread context switch) 60 | /// \param[in] id TrustZone memory slot identifier 61 | /// \return execution status (1: success, 0: error) 62 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 63 | 64 | /// Store secure context (called on RTOS thread context switch) 65 | /// \param[in] id TrustZone memory slot identifier 66 | /// \return execution status (1: success, 0: error) 67 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 68 | 69 | #endif // TZ_CONTEXT_H 70 | -------------------------------------------------------------------------------- /Deployment/Source/NN/DNN/dnn.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* 20 | * Description: Keyword spotting DNN model example code 21 | */ 22 | 23 | /* Network Structure 24 | 25 | 10x25 input features 26 | | 27 | IP1 : Innerproduct (weights: 250x144) 28 | | 29 | IP2 : Innerproduct (weights: 144x144) 30 | | 31 | IP3 : Innerproduct (weights: 144x144) 32 | | 33 | IP4 : Innerproduct (weights: 144x12) 34 | | 35 | 12 outputs 36 | 37 | */ 38 | 39 | #include "dnn.h" 40 | 41 | const q7_t DNN::ip1_wt[IP1_WT_DIM]=IP1_WT; 42 | const q7_t DNN::ip1_bias[IP1_OUT_DIM]=IP1_BIAS; 43 | const q7_t DNN::ip2_wt[IP2_WT_DIM]=IP2_WT; 44 | const q7_t DNN::ip2_bias[IP2_OUT_DIM]=IP2_BIAS; 45 | const q7_t DNN::ip3_wt[IP3_WT_DIM]=IP3_WT; 46 | const q7_t DNN::ip3_bias[IP3_OUT_DIM]=IP3_BIAS; 47 | const q7_t DNN::ip4_wt[IP4_WT_DIM]=IP4_WT; 48 | const q7_t DNN::ip4_bias[OUT_DIM]=IP4_BIAS; 49 | 50 | DNN::DNN() 51 | { 52 | scratch_pad = new q7_t[SCRATCH_BUFFER_SIZE]; 53 | ip1_out = scratch_pad; 54 | ip2_out = ip1_out+IP1_OUT_DIM; 55 | ip3_out = ip1_out; 56 | vec_buffer = (q15_t*)(ip1_out+IP1_OUT_DIM+IP2_OUT_DIM); 57 | frame_len = FRAME_LEN; 58 | frame_shift = FRAME_SHIFT; 59 | num_mfcc_features = NUM_MFCC_COEFFS; 60 | num_frames = NUM_FRAMES; 61 | num_out_classes = OUT_DIM; 62 | in_dec_bits = MFCC_DEC_BITS; 63 | } 64 | 65 | DNN::~DNN() 66 | { 67 | delete scratch_pad; 68 | } 69 | 70 | void DNN::run_nn(q7_t* in_data, q7_t* out_data) 71 | { 72 | // Run all layers 73 | 74 | // IP1 75 | arm_fully_connected_q7(in_data, ip1_wt, IN_DIM, IP1_OUT_DIM, 1, 7, ip1_bias, ip1_out, vec_buffer); 76 | // RELU1 77 | arm_relu_q7(ip1_out, IP1_OUT_DIM); 78 | 79 | // IP2 80 | arm_fully_connected_q7(ip1_out, ip2_wt, IP1_OUT_DIM, IP2_OUT_DIM, 2, 8, ip2_bias, ip2_out, vec_buffer); 81 | // RELU2 82 | arm_relu_q7(ip2_out, IP2_OUT_DIM); 83 | 84 | // IP3 85 | arm_fully_connected_q7(ip2_out, ip3_wt, IP2_OUT_DIM, IP3_OUT_DIM, 2, 9, ip3_bias, ip3_out, vec_buffer); 86 | // RELU3 87 | arm_relu_q7(ip3_out, IP3_OUT_DIM); 88 | 89 | // IP4 90 | arm_fully_connected_q7(ip3_out, ip4_wt, IP3_OUT_DIM, OUT_DIM, 0, 6, ip4_bias, out_data, vec_buffer); 91 | 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/PortIn.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_PORTIN_H 17 | #define MBED_PORTIN_H 18 | 19 | #include "platform/platform.h" 20 | 21 | #if defined (DEVICE_PORTIN) || defined(DOXYGEN_ONLY) 22 | 23 | #include "hal/port_api.h" 24 | #include "platform/mbed_critical.h" 25 | 26 | namespace mbed { 27 | /** \addtogroup drivers */ 28 | 29 | /** A multiple pin digital input 30 | * 31 | * @note Synchronization level: Interrupt safe 32 | * 33 | * Example: 34 | * @code 35 | * // Switch on an LED if any of mbed pins 21-26 is high 36 | * 37 | * #include "mbed.h" 38 | * 39 | * PortIn p(Port2, 0x0000003F); // p21-p26 40 | * DigitalOut ind(LED4); 41 | * 42 | * int main() { 43 | * while(1) { 44 | * int pins = p.read(); 45 | * if(pins) { 46 | * ind = 1; 47 | * } else { 48 | * ind = 0; 49 | * } 50 | * } 51 | * } 52 | * @endcode 53 | * @ingroup drivers 54 | */ 55 | class PortIn { 56 | public: 57 | 58 | /** Create an PortIn, connected to the specified port 59 | * 60 | * @param port Port to connect to (Port0-Port5) 61 | * @param mask A bitmask to identify which bits in the port should be included (0 - ignore) 62 | */ 63 | PortIn(PortName port, int mask = 0xFFFFFFFF) { 64 | core_util_critical_section_enter(); 65 | port_init(&_port, port, mask, PIN_INPUT); 66 | core_util_critical_section_exit(); 67 | } 68 | 69 | /** Read the value currently output on the port 70 | * 71 | * @returns 72 | * An integer with each bit corresponding to associated port pin setting 73 | */ 74 | int read() { 75 | return port_read(&_port); 76 | } 77 | 78 | /** Set the input pin mode 79 | * 80 | * @param mode PullUp, PullDown, PullNone, OpenDrain 81 | */ 82 | void mode(PinMode mode) { 83 | core_util_critical_section_enter(); 84 | port_mode(&_port, mode); 85 | core_util_critical_section_exit(); 86 | } 87 | 88 | /** A shorthand for read() 89 | */ 90 | operator int() { 91 | return read(); 92 | } 93 | 94 | private: 95 | port_t _port; 96 | }; 97 | 98 | } // namespace mbed 99 | 100 | #endif 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/us_ticker_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2006-2015 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_US_TICKER_API_H 20 | #define MBED_US_TICKER_API_H 21 | 22 | #include 23 | #include "hal/ticker_api.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /** 30 | * \defgroup hal_UsTicker Microseconds Ticker Functions 31 | * @{ 32 | */ 33 | 34 | typedef void (*ticker_irq_handler_type)(const ticker_data_t *const); 35 | 36 | /** Set ticker IRQ handler 37 | * 38 | * @param ticker_irq_handler IRQ handler to be connected 39 | * 40 | * @return previous ticker IRQ handler 41 | * 42 | * @note by default IRQ handler is set to ticker_irq_handler() 43 | * @note this function is primarily for testing purposes and it's not required part of HAL implementation 44 | * 45 | */ 46 | ticker_irq_handler_type set_us_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler); 47 | 48 | /** Get ticker's data 49 | * 50 | * @return The low power ticker data 51 | */ 52 | const ticker_data_t* get_us_ticker_data(void); 53 | 54 | 55 | /** The wrapper for ticker_irq_handler, to pass us ticker's data 56 | * 57 | */ 58 | void us_ticker_irq_handler(void); 59 | 60 | /* HAL us ticker */ 61 | 62 | /** Initialize the ticker 63 | * 64 | */ 65 | void us_ticker_init(void); 66 | 67 | /** Read the current counter 68 | * 69 | * @return The current timer's counter value in microseconds 70 | */ 71 | uint32_t us_ticker_read(void); 72 | 73 | /** Set interrupt for specified timestamp 74 | * 75 | * @param timestamp The time in microseconds to be set 76 | */ 77 | void us_ticker_set_interrupt(timestamp_t timestamp); 78 | 79 | /** Disable us ticker interrupt 80 | * 81 | */ 82 | void us_ticker_disable_interrupt(void); 83 | 84 | /** Clear us ticker interrupt 85 | * 86 | */ 87 | void us_ticker_clear_interrupt(void); 88 | 89 | /** Set pending interrupt that should be fired right away. 90 | * 91 | * The ticker should be initialized prior calling this function. 92 | */ 93 | void us_ticker_fire_interrupt(void); 94 | 95 | /** Get frequency and counter bits of this ticker. 96 | * 97 | */ 98 | const ticker_info_t* us_ticker_get_info(void); 99 | 100 | /**@}*/ 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif 107 | 108 | /** @}*/ 109 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/mbed_rtx.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2016 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef MBED_MBED_RTX_H 18 | #define MBED_MBED_RTX_H 19 | 20 | #if defined(TARGET_K20D50M) 21 | 22 | #ifndef INITIAL_SP 23 | #define INITIAL_SP (0x10008000UL) 24 | #endif 25 | 26 | #elif defined(TARGET_TEENSY3_1) 27 | 28 | #ifndef INITIAL_SP 29 | #define INITIAL_SP (0x20008000UL) 30 | #endif 31 | 32 | #elif defined(TARGET_MCU_K22F) 33 | 34 | #ifndef INITIAL_SP 35 | #define INITIAL_SP (0x20010000UL) 36 | #endif 37 | 38 | #elif defined(TARGET_K66F) 39 | 40 | #ifndef INITIAL_SP 41 | #define INITIAL_SP (0x20030000UL) 42 | #endif 43 | 44 | #elif defined(TARGET_KL27Z) 45 | 46 | #ifndef INITIAL_SP 47 | #define INITIAL_SP (0x20003000UL) 48 | #endif 49 | 50 | #elif defined(TARGET_KL43Z) 51 | 52 | #ifndef INITIAL_SP 53 | #define INITIAL_SP (0x20006000UL) 54 | #endif 55 | 56 | #elif defined(TARGET_KL05Z) 57 | 58 | #ifndef INITIAL_SP 59 | #define INITIAL_SP (0x20000C00UL) 60 | #endif 61 | 62 | #elif defined(TARGET_KL25Z) 63 | 64 | #ifndef INITIAL_SP 65 | #define INITIAL_SP (0x20003000UL) 66 | #endif 67 | 68 | #elif defined(TARGET_KL26Z) 69 | 70 | #ifndef INITIAL_SP 71 | #define INITIAL_SP (0x20003000UL) 72 | #endif 73 | 74 | #elif defined(TARGET_KL46Z) 75 | 76 | #ifndef INITIAL_SP 77 | #define INITIAL_SP (0x20006000UL) 78 | #endif 79 | 80 | #elif defined(TARGET_KL82Z) 81 | 82 | #ifndef INITIAL_SP 83 | #define INITIAL_SP (0x20012000UL) 84 | #endif 85 | 86 | #elif defined(TARGET_K64F) 87 | 88 | #ifndef INITIAL_SP 89 | #define INITIAL_SP (0x20030000UL) 90 | #endif 91 | 92 | #elif defined(TARGET_KW24D) 93 | 94 | #ifndef INITIAL_SP 95 | #define INITIAL_SP (0x20008000UL) 96 | #endif 97 | 98 | #elif defined(TARGET_KW41Z) 99 | 100 | #ifndef INITIAL_SP 101 | #define INITIAL_SP (0x20018000UL) 102 | #endif 103 | 104 | #elif defined(TARGET_K82F) 105 | 106 | #ifndef INITIAL_SP 107 | #define INITIAL_SP (0x20030000UL) 108 | #endif 109 | 110 | #elif defined(TARGET_RO359B) 111 | 112 | #ifndef INITIAL_SP 113 | #define INITIAL_SP (0x20030000UL) 114 | #endif 115 | 116 | #endif 117 | 118 | #endif // MBED_MBED_RTX_H 119 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_semihost_api.h: -------------------------------------------------------------------------------- 1 | 2 | /* mbed Microcontroller Library 3 | * Copyright (c) 2006-2013 ARM Limited 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #ifndef MBED_SEMIHOST_H 18 | #define MBED_SEMIHOST_H 19 | 20 | #include "device.h" 21 | #include "platform/mbed_toolchain.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #if DEVICE_SEMIHOST 28 | 29 | #if !defined(__CC_ARM) && !defined(__ARMCC_VERSION) 30 | 31 | #if defined(__ICCARM__) 32 | static inline int __semihost(int reason, const void *arg) { 33 | return __semihosting(reason, (void*)arg); 34 | } 35 | #else 36 | 37 | #ifdef __thumb__ 38 | # define AngelSWI 0xAB 39 | # define AngelSWIInsn "bkpt" 40 | # define AngelSWIAsm bkpt 41 | #else 42 | # define AngelSWI 0x123456 43 | # define AngelSWIInsn "swi" 44 | # define AngelSWIAsm swi 45 | #endif 46 | 47 | static inline int __semihost(int reason, const void *arg) { 48 | int value; 49 | 50 | asm volatile ( 51 | "mov r0, %1" "\n\t" 52 | "mov r1, %2" "\n\t" 53 | AngelSWIInsn " %a3" "\n\t" 54 | "mov %0, r0" 55 | : "=r" (value) /* output operands */ 56 | : "r" (reason), "r" (arg), "i" (AngelSWI) /* input operands */ 57 | : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */ 58 | ); 59 | 60 | return value; 61 | } 62 | #endif 63 | #endif 64 | 65 | #if DEVICE_LOCALFILESYSTEM 66 | FILEHANDLE semihost_open(const char* name, int openmode); 67 | int semihost_close (FILEHANDLE fh); 68 | int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode); 69 | int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode); 70 | int semihost_ensure(FILEHANDLE fh); 71 | long semihost_flen (FILEHANDLE fh); 72 | int semihost_seek (FILEHANDLE fh, long position); 73 | int semihost_istty (FILEHANDLE fh); 74 | 75 | int semihost_remove(const char *name); 76 | int semihost_rename(const char *old_name, const char *new_name); 77 | #endif 78 | 79 | int semihost_uid(char *uid); 80 | int semihost_reset(void); 81 | int semihost_vbus(void); 82 | int semihost_powerdown(void); 83 | int semihost_exit(void); 84 | 85 | int semihost_connected(void); 86 | int semihost_disabledebug(void); 87 | 88 | #endif 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif 95 | 96 | 97 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/lp_ticker_api.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup hal */ 3 | /** @{*/ 4 | /* mbed Microcontroller Library 5 | * Copyright (c) 2015 ARM Limited 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef MBED_LPTICKER_API_H 20 | #define MBED_LPTICKER_API_H 21 | 22 | #include "device.h" 23 | 24 | #if DEVICE_LOWPOWERTIMER 25 | 26 | #include "hal/ticker_api.h" 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** 33 | * \defgroup hal_LpTicker Low Power Ticker Functions 34 | * @{ 35 | */ 36 | 37 | typedef void (*ticker_irq_handler_type)(const ticker_data_t *const); 38 | 39 | /** Set low power ticker IRQ handler 40 | * 41 | * @param ticker_irq_handler IRQ handler to be connected 42 | * 43 | * @return previous ticker IRQ handler 44 | * 45 | * @note by default IRQ handler is set to ticker_irq_handler() 46 | * @note this function is primarily for testing purposes and it's not required part of HAL implementation 47 | * 48 | */ 49 | ticker_irq_handler_type set_lp_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler); 50 | 51 | /** Get low power ticker's data 52 | * 53 | * @return The low power ticker data 54 | */ 55 | const ticker_data_t* get_lp_ticker_data(void); 56 | 57 | /** The wrapper for ticker_irq_handler, to pass lp ticker's data 58 | * 59 | */ 60 | void lp_ticker_irq_handler(void); 61 | 62 | /* HAL lp ticker */ 63 | 64 | /** Initialize the low power ticker 65 | * 66 | */ 67 | void lp_ticker_init(void); 68 | 69 | /** Read the current counter 70 | * 71 | * @return The current timer's counter value in microseconds 72 | */ 73 | uint32_t lp_ticker_read(void); 74 | 75 | /** Set interrupt for specified timestamp 76 | * 77 | * @param timestamp The time in microseconds to be set 78 | */ 79 | void lp_ticker_set_interrupt(timestamp_t timestamp); 80 | 81 | /** Disable low power ticker interrupt 82 | * 83 | */ 84 | void lp_ticker_disable_interrupt(void); 85 | 86 | /** Clear the low power ticker interrupt 87 | * 88 | */ 89 | void lp_ticker_clear_interrupt(void); 90 | 91 | /** Set pending interrupt that should be fired right away. 92 | * 93 | * The ticker should be initialized prior calling this function. 94 | */ 95 | void lp_ticker_fire_interrupt(void); 96 | 97 | /** Get frequency and counter bits of this ticker. 98 | * 99 | */ 100 | const ticker_info_t* lp_ticker_get_info(void); 101 | 102 | /**@}*/ 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif 109 | 110 | #endif 111 | 112 | /** @}*/ 113 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_rtc_time.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup platform */ 3 | /** @{*/ 4 | /** 5 | * \defgroup platform_rtc_time rtc_time functions 6 | * @{ 7 | */ 8 | /* mbed Microcontroller Library 9 | * Copyright (c) 2006-2013 ARM Limited 10 | * 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 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | #include 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** Implementation of the C time.h functions 31 | * 32 | * Provides mechanisms to set and read the current time, based 33 | * on the microcontroller Real-Time Clock (RTC), plus some 34 | * standard C manipulation and formating functions. 35 | * 36 | * Example: 37 | * @code 38 | * #include "mbed.h" 39 | * 40 | * int main() { 41 | * set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37 42 | * 43 | * while(1) { 44 | * time_t seconds = time(NULL); 45 | * 46 | * printf("Time as seconds since January 1, 1970 = %d\n", seconds); 47 | * 48 | * printf("Time as a basic string = %s", ctime(&seconds)); 49 | * 50 | * char buffer[32]; 51 | * strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); 52 | * printf("Time as a custom formatted string = %s", buffer); 53 | * 54 | * wait(1); 55 | * } 56 | * } 57 | * @endcode 58 | */ 59 | 60 | /** Set the current time 61 | * 62 | * Initialises and sets the time of the microcontroller Real-Time Clock (RTC) 63 | * to the time represented by the number of seconds since January 1, 1970 64 | * (the UNIX timestamp). 65 | * 66 | * @param t Number of seconds since January 1, 1970 (the UNIX timestamp) 67 | * 68 | * @note Synchronization level: Thread safe 69 | * 70 | * Example: 71 | * @code 72 | * #include "mbed.h" 73 | * 74 | * int main() { 75 | * set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37 76 | * } 77 | * @endcode 78 | */ 79 | void set_time(time_t t); 80 | 81 | /** Attach an external RTC to be used for the C time functions 82 | * 83 | * @note Synchronization level: Thread safe 84 | * 85 | * @param read_rtc pointer to function which returns current UNIX timestamp 86 | * @param write_rtc pointer to function which sets current UNIX timestamp, can be NULL 87 | * @param init_rtc pointer to funtion which initializes RTC, can be NULL 88 | * @param isenabled_rtc pointer to function wich returns if the rtc is enabled, can be NULL 89 | */ 90 | void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void)); 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | /** @}*/ 97 | /** @}*/ 98 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/Timer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_TIMER_H 17 | #define MBED_TIMER_H 18 | 19 | #include "platform/platform.h" 20 | #include "hal/ticker_api.h" 21 | #include "platform/NonCopyable.h" 22 | #include "platform/mbed_power_mgmt.h" 23 | 24 | namespace mbed { 25 | /** \addtogroup drivers */ 26 | 27 | /** A general purpose timer 28 | * 29 | * @note Synchronization level: Interrupt safe 30 | * 31 | * Example: 32 | * @code 33 | * // Count the time to toggle a LED 34 | * 35 | * #include "mbed.h" 36 | * 37 | * Timer timer; 38 | * DigitalOut led(LED1); 39 | * int begin, end; 40 | * 41 | * int main() { 42 | * timer.start(); 43 | * begin = timer.read_us(); 44 | * led = !led; 45 | * end = timer.read_us(); 46 | * printf("Toggle the led takes %d us", end - begin); 47 | * } 48 | * @endcode 49 | * @ingroup drivers 50 | */ 51 | class Timer : private NonCopyable { 52 | 53 | public: 54 | Timer(); 55 | Timer(const ticker_data_t *data); 56 | ~Timer(); 57 | 58 | /** Start the timer 59 | */ 60 | void start(); 61 | 62 | /** Stop the timer 63 | */ 64 | void stop(); 65 | 66 | /** Reset the timer to 0. 67 | * 68 | * If it was already counting, it will continue 69 | */ 70 | void reset(); 71 | 72 | /** Get the time passed in seconds 73 | * 74 | * @returns Time passed in seconds 75 | */ 76 | float read(); 77 | 78 | /** Get the time passed in milli-seconds 79 | * 80 | * @returns Time passed in milli seconds 81 | */ 82 | int read_ms(); 83 | 84 | /** Get the time passed in micro-seconds 85 | * 86 | * @returns Time passed in micro seconds 87 | */ 88 | int read_us(); 89 | 90 | /** An operator shorthand for read() 91 | */ 92 | operator float(); 93 | 94 | /** Get in a high resolution type the time passed in micro-seconds. 95 | */ 96 | us_timestamp_t read_high_resolution_us(); 97 | 98 | protected: 99 | us_timestamp_t slicetime(); 100 | int _running; // whether the timer is running 101 | us_timestamp_t _start; // the start time of the latest slice 102 | us_timestamp_t _time; // any accumulated time from previous slices 103 | const ticker_data_t *_ticker_data; 104 | bool _lock_deepsleep; // flag which indicates if deep-sleep should be disabled 105 | }; 106 | 107 | } // namespace mbed 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/mbed_stats.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup platform */ 3 | /** @{*/ 4 | /** 5 | * \defgroup platform_stats stats functions 6 | * @{ 7 | */ 8 | /* mbed Microcontroller Library 9 | * Copyright (c) 2016-2016 ARM Limited 10 | * 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 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | #ifndef MBED_STATS_H 24 | #define MBED_STATS_H 25 | #include 26 | #include 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** 33 | * struct mbed_stats_heap_t definition 34 | */ 35 | typedef struct { 36 | uint32_t current_size; /**< Bytes allocated currently. */ 37 | uint32_t max_size; /**< Max bytes allocated at a given time. */ 38 | uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */ 39 | uint32_t reserved_size; /**< Current number of bytes allocated for the heap. */ 40 | uint32_t alloc_cnt; /**< Current number of allocations. */ 41 | uint32_t alloc_fail_cnt; /**< Number of failed allocations. */ 42 | } mbed_stats_heap_t; 43 | 44 | /** 45 | * Fill the passed in heap stat structure with heap stats. 46 | * 47 | * @param stats A pointer to the mbed_stats_heap_t structure to fill 48 | */ 49 | void mbed_stats_heap_get(mbed_stats_heap_t *stats); 50 | 51 | /** 52 | * struct mbed_stats_stack_t definition 53 | */ 54 | typedef struct { 55 | uint32_t thread_id; /**< Identifier for thread that owns the stack or 0 if multiple threads. */ 56 | uint32_t max_size; /**< Maximum number of bytes used on the stack. */ 57 | uint32_t reserved_size; /**< Current number of bytes allocated for the stack. */ 58 | uint32_t stack_cnt; /**< Number of stacks stats accumulated in the structure. */ 59 | } mbed_stats_stack_t; 60 | 61 | /** 62 | * Fill the passed in structure with stack stats accumulated for all threads. The thread_id will be 0 63 | * and stack_cnt will represent number of threads. 64 | * 65 | * @param stats A pointer to the mbed_stats_stack_t structure to fill 66 | */ 67 | void mbed_stats_stack_get(mbed_stats_stack_t *stats); 68 | 69 | /** 70 | * Fill the passed array of stat structures with the stack stats for each available thread. 71 | * 72 | * @param stats A pointer to an array of mbed_stats_stack_t structures to fill 73 | * @param count The number of mbed_stats_stack_t structures in the provided array 74 | * @return The number of mbed_stats_stack_t structures that have been filled, 75 | * this is equal to the number of stacks on the system. 76 | */ 77 | size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif 84 | 85 | /** @}*/ 86 | 87 | /** @}*/ 88 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/dma_reqs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Freescale Semiconductor, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * o Redistributions of source code must retain the above copyright notice, this list 9 | * of conditions and the following disclaimer. 10 | * 11 | * o Redistributions in binary form must reproduce the above copyright notice, this 12 | * list of conditions and the following disclaimer in the documentation and/or 13 | * other materials provided with the distribution. 14 | * 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from this 17 | * software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _FSL_DMA_REQS_H_ 32 | #define _FSL_DMA_REQS_H_ 33 | 34 | #include "fsl_common.h" 35 | 36 | /* Array for DSPI DMA TX requests */ 37 | #define SPI_DMA_TX_REQUEST_NUMBERS \ 38 | { \ 39 | kDmaRequestMux0SPI0Tx, kDmaRequestMux0SPI1, kDmaRequestMux0SPI2 \ 40 | } 41 | 42 | /* Array for DSPI DMA RX requests */ 43 | #define SPI_DMA_RX_REQUEST_NUMBERS \ 44 | { \ 45 | kDmaRequestMux0SPI0Rx, kDmaRequestMux0SPI1, kDmaRequestMux0SPI2 \ 46 | } 47 | 48 | /* Array for UART DMA TX requests */ 49 | #define UART_DMA_TX_REQUEST_NUMBERS \ 50 | { \ 51 | kDmaRequestMux0UART0Tx, kDmaRequestMux0UART1Tx, kDmaRequestMux0UART2Tx, \ 52 | kDmaRequestMux0UART3Tx, kDmaRequestMux0UART4, kDmaRequestMux0UART5 \ 53 | } 54 | 55 | /* Array for UART DMA RX requests */ 56 | #define UART_DMA_RX_REQUEST_NUMBERS \ 57 | { \ 58 | kDmaRequestMux0UART0Rx, kDmaRequestMux0UART1Rx, kDmaRequestMux0UART2Rx, \ 59 | kDmaRequestMux0UART3Rx, kDmaRequestMux0UART4, kDmaRequestMux0UART5 \ 60 | } 61 | 62 | #endif /* _FSL_DMA_REQS_H_ */ 63 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/hal/flash_data.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2017 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FLASH_DATA_H 17 | #define MBED_FLASH_DATA_H 18 | 19 | #include 20 | 21 | /** Target flash algorithm structure 22 | */ 23 | typedef struct { 24 | const uint32_t init; /**< Init function address */ 25 | const uint32_t uninit; /**< Uninit function address */ 26 | const uint32_t erase_sector; /**< Erase sector function address */ 27 | const uint32_t program_page; /**< Program page function address */ 28 | const uint32_t static_base; /**< Static base address */ 29 | uint32_t *algo_blob; /**< Pointer to flash algo binary blob */ 30 | } flash_algo_t; 31 | 32 | /** Sector information structure 33 | */ 34 | typedef struct { 35 | const uint32_t start; /**< Sector start address */ 36 | const uint32_t size; /**< Sector size */ 37 | } sector_info_t; 38 | 39 | /** Flash configuration structure 40 | */ 41 | typedef struct { 42 | const uint32_t page_size; /**< The minimum program page size that can be written */ 43 | const uint32_t flash_start; /**< Start address of the flash <0, flash_size) */ 44 | const uint32_t flash_size; /**< Flash size. The size is accumulative sum of all sector sizes */ 45 | const sector_info_t *sectors; /**< List of sectors - sector can vary in sizes */ 46 | const uint32_t sector_info_count; /**< Number of sectors */ 47 | } flash_target_config_t; 48 | 49 | /** Target flash configuration 50 | */ 51 | struct flash_s { 52 | const flash_target_config_t *target_config; 53 | const flash_algo_t *flash_algo; 54 | }; 55 | 56 | /** Flash algo argument structure 57 | * Contains all registers that should be preserved 58 | */ 59 | typedef struct { 60 | uint32_t r0; 61 | uint32_t r1; 62 | uint32_t r2; 63 | uint32_t r3; 64 | uint32_t r9; 65 | uint32_t pc; 66 | } args_t; 67 | 68 | typedef int32_t (*flash_algo_jump_t)(args_t*); 69 | 70 | // prototypes for flash algo CMSIS API 71 | 72 | typedef int (*CMSIS_Algo_Function_Init)(unsigned long adr, unsigned long clk, unsigned long fnc); 73 | typedef int (*CMSIS_Algo_Function_UnInit)(unsigned long fnc); 74 | typedef int (*CMSIS_Algo_Function_EraseSector)(unsigned long adr); 75 | typedef int (*CMSIS_Algo_Function_EraseChip)(void); 76 | typedef int (*CMSIS_Algo_Function_ProgramPage)(unsigned long adr, unsigned long sz, unsigned char *buf); 77 | typedef unsigned long (*CMSIS_Algo_Function_Verify)(unsigned long adr, unsigned long sz, unsigned char *buf); 78 | 79 | #ifdef __cplusplus 80 | extern "C" { 81 | #endif 82 | 83 | /* Set target configuration 84 | */ 85 | void flash_set_target_config(flash_t *obj); 86 | 87 | #ifdef __cplusplus 88 | }; 89 | #endif 90 | 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/RawSerial.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_RAW_SERIAL_H 17 | #define MBED_RAW_SERIAL_H 18 | 19 | #include "platform/platform.h" 20 | 21 | #if defined (DEVICE_SERIAL) || defined(DOXYGEN_ONLY) 22 | 23 | #include "drivers/SerialBase.h" 24 | #include "hal/serial_api.h" 25 | #include "platform/NonCopyable.h" 26 | 27 | namespace mbed { 28 | /** \addtogroup drivers */ 29 | 30 | /** A serial port (UART) for communication with other serial devices 31 | * This is a variation of the Serial class that doesn't use streams, 32 | * thus making it safe to use in interrupt handlers with the RTOS. 33 | * 34 | * Can be used for Full Duplex communication, or Simplex by specifying 35 | * one pin as NC (Not Connected) 36 | * 37 | * @note Synchronization level: Not protected 38 | * 39 | * Example: 40 | * @code 41 | * // Send a char to the PC 42 | * 43 | * #include "mbed.h" 44 | * 45 | * RawSerial pc(USBTX, USBRX); 46 | * 47 | * int main() { 48 | * pc.putc('A'); 49 | * } 50 | * @endcode 51 | * @ingroup drivers 52 | */ 53 | class RawSerial: public SerialBase, private NonCopyable { 54 | 55 | public: 56 | /** Create a RawSerial port, connected to the specified transmit and receive pins, with the specified baud. 57 | * 58 | * @param tx Transmit pin 59 | * @param rx Receive pin 60 | * @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) 61 | * 62 | * @note 63 | * Either tx or rx may be specified as NC if unused 64 | */ 65 | RawSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); 66 | 67 | /** Write a char to the serial port 68 | * 69 | * @param c The char to write 70 | * 71 | * @returns The written char or -1 if an error occurred 72 | */ 73 | int putc(int c); 74 | 75 | /** Read a char from the serial port 76 | * 77 | * @returns The char read from the serial port 78 | */ 79 | int getc(); 80 | 81 | /** Write a string to the serial port 82 | * 83 | * @param str The string to write 84 | * 85 | * @returns 0 if the write succeeds, EOF for error 86 | */ 87 | int puts(const char *str); 88 | 89 | int printf(const char *format, ...); 90 | 91 | protected: 92 | 93 | /* Acquire exclusive access to this serial port 94 | */ 95 | virtual void lock(void); 96 | 97 | /* Release exclusive access to this serial port 98 | */ 99 | virtual void unlock(void); 100 | }; 101 | 102 | } // namespace mbed 103 | 104 | #endif 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/drivers/PortOut.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_PORTOUT_H 17 | #define MBED_PORTOUT_H 18 | 19 | #include "platform/platform.h" 20 | 21 | #if defined (DEVICE_PORTOUT) || defined(DOXYGEN_ONLY) 22 | 23 | #include "hal/port_api.h" 24 | #include "platform/mbed_critical.h" 25 | 26 | namespace mbed { 27 | /** \addtogroup drivers */ 28 | /** A multiple pin digital out 29 | * 30 | * @note Synchronization level: Interrupt safe 31 | * 32 | * Example: 33 | * @code 34 | * // Toggle all four LEDs 35 | * 36 | * #include "mbed.h" 37 | * 38 | * // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23 39 | * #define LED_MASK 0x00B40000 40 | * 41 | * PortOut ledport(Port1, LED_MASK); 42 | * 43 | * int main() { 44 | * while(1) { 45 | * ledport = LED_MASK; 46 | * wait(1); 47 | * ledport = 0; 48 | * wait(1); 49 | * } 50 | * } 51 | * @endcode 52 | * @ingroup drivers 53 | */ 54 | class PortOut { 55 | public: 56 | 57 | /** Create an PortOut, connected to the specified port 58 | * 59 | * @param port Port to connect to (Port0-Port5) 60 | * @param mask A bitmask to identify which bits in the port should be included (0 - ignore) 61 | */ 62 | PortOut(PortName port, int mask = 0xFFFFFFFF) { 63 | core_util_critical_section_enter(); 64 | port_init(&_port, port, mask, PIN_OUTPUT); 65 | core_util_critical_section_exit(); 66 | } 67 | 68 | /** Write the value to the output port 69 | * 70 | * @param value An integer specifying a bit to write for every corresponding PortOut pin 71 | */ 72 | void write(int value) { 73 | port_write(&_port, value); 74 | } 75 | 76 | /** Read the value currently output on the port 77 | * 78 | * @returns 79 | * An integer with each bit corresponding to associated PortOut pin setting 80 | */ 81 | int read() { 82 | return port_read(&_port); 83 | } 84 | 85 | /** A shorthand for write() 86 | * \sa PortOut::write() 87 | */ 88 | PortOut& operator= (int value) { 89 | write(value); 90 | return *this; 91 | } 92 | 93 | /** A shorthand for read() 94 | * \sa PortOut::read() 95 | */ 96 | PortOut& operator= (PortOut& rhs) { 97 | write(rhs.read()); 98 | return *this; 99 | } 100 | 101 | /** A shorthand for read() 102 | * \sa PortOut::read() 103 | */ 104 | operator int() { 105 | return read(); 106 | } 107 | 108 | private: 109 | port_t _port; 110 | }; 111 | 112 | } // namespace mbed 113 | 114 | #endif 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/FileSystemLike.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILESYSTEMLIKE_H 17 | #define MBED_FILESYSTEMLIKE_H 18 | 19 | #include "platform/platform.h" 20 | 21 | #include "platform/FileSystemHandle.h" 22 | #include "platform/FileHandle.h" 23 | #include "platform/DirHandle.h" 24 | #include "platform/NonCopyable.h" 25 | 26 | namespace mbed { 27 | /** \addtogroup platform */ 28 | /** @{*/ 29 | /** 30 | * \defgroup platform_FileSystemLike FileSystemLike functions 31 | * @{ 32 | */ 33 | 34 | 35 | /** A filesystem-like object is one that can be used to open file-like 36 | * objects though it by fopen("/name/filename", mode) 37 | * 38 | * Implementations must define at least open (the default definitions 39 | * of the rest of the functions just return error values). 40 | * 41 | * @note Synchronization level: Set by subclass 42 | */ 43 | class FileSystemLike : public FileSystemHandle, public FileBase, private NonCopyable { 44 | public: 45 | /** FileSystemLike lifetime 46 | */ 47 | FileSystemLike(const char *name = NULL) : FileBase(name, FileSystemPathType) {} 48 | virtual ~FileSystemLike() {} 49 | 50 | // Inherited functions with name conflicts 51 | using FileSystemHandle::open; 52 | 53 | /** Open a file on the filesystem 54 | * 55 | * @param path The name of the file to open 56 | * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR, 57 | * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND 58 | * @return A file handle on success, NULL on failure 59 | * @deprecated Replaced by `int open(FileHandle **, ...)` for propagating error codes 60 | */ 61 | MBED_DEPRECATED_SINCE("mbed-os-5.5", 62 | "Replaced by `int open(FileHandle **, ...)` for propagating error codes") 63 | FileHandle *open(const char *path, int flags) 64 | { 65 | FileHandle *file; 66 | int err = open(&file, path, flags); 67 | return err ? NULL : file; 68 | } 69 | 70 | /** Open a directory on the filesystem 71 | * 72 | * @param path Name of the directory to open 73 | * @return A directory handle on success, NULL on failure 74 | * @deprecated Replaced by `int open(DirHandle **, ...)` for propagating error codes 75 | */ 76 | MBED_DEPRECATED_SINCE("mbed-os-5.5", 77 | "Replaced by `int open(DirHandle **, ...)` for propagating error codes") 78 | DirHandle *opendir(const char *path) 79 | { 80 | DirHandle *dir; 81 | int err = open(&dir, path); 82 | return err ? NULL : dir; 83 | } 84 | }; 85 | 86 | /**@}*/ 87 | 88 | /**@}*/ 89 | 90 | } // namespace mbed 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/FunctionPointer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FUNCTIONPOINTER_H 17 | #define MBED_FUNCTIONPOINTER_H 18 | 19 | #include "platform/Callback.h" 20 | #include "platform/mbed_toolchain.h" 21 | #include 22 | #include 23 | 24 | namespace mbed { 25 | /** \addtogroup platform */ 26 | /** @{*/ 27 | /** 28 | * \defgroup platform_FunctionPointer FunctionPointer class 29 | * @{ 30 | */ 31 | 32 | // Declarations for backwards compatibility 33 | // To be foward compatible, code should adopt the Callback class 34 | template 35 | class FunctionPointerArg1 : public Callback { 36 | public: 37 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 38 | "FunctionPointerArg1 has been replaced by Callback") 39 | FunctionPointerArg1(R (*function)(A1) = 0) 40 | : Callback(function) {} 41 | 42 | template 43 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 44 | "FunctionPointerArg1 has been replaced by Callback") 45 | FunctionPointerArg1(T *object, R (T::*member)(A1)) 46 | : Callback(object, member) {} 47 | 48 | R (*get_function())(A1) { 49 | return *reinterpret_cast(this); 50 | } 51 | 52 | R call(A1 a1) const { 53 | if (!Callback::operator bool()) { 54 | return (R)0; 55 | } 56 | 57 | return Callback::call(a1); 58 | } 59 | 60 | R operator()(A1 a1) const { 61 | return Callback::call(a1); 62 | } 63 | }; 64 | 65 | template 66 | class FunctionPointerArg1 : public Callback { 67 | public: 68 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 69 | "FunctionPointer has been replaced by Callback") 70 | FunctionPointerArg1(R (*function)() = 0) 71 | : Callback(function) {} 72 | 73 | template 74 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 75 | "FunctionPointer has been replaced by Callback") 76 | FunctionPointerArg1(T *object, R (T::*member)()) 77 | : Callback(object, member) {} 78 | 79 | R (*get_function())() { 80 | return *reinterpret_cast(this); 81 | } 82 | 83 | R call() const { 84 | if (!Callback::operator bool()) { 85 | return (R)0; 86 | } 87 | 88 | return Callback::call(); 89 | } 90 | 91 | R operator()() const { 92 | return Callback::call(); 93 | } 94 | }; 95 | 96 | typedef FunctionPointerArg1 FunctionPointer; 97 | 98 | /**@}*/ 99 | 100 | /**@}*/ 101 | 102 | 103 | } // namespace mbed 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /Deployment/Examples/simple_test_k64f_gcc/mbed/platform/SingletonPtr.h: -------------------------------------------------------------------------------- 1 | 2 | /** \addtogroup platform */ 3 | /** @{*/ 4 | /** 5 | * \defgroup platform_SingletonPtr SingletonPtr class 6 | * @{ 7 | */ 8 | /* mbed Microcontroller Library 9 | * Copyright (c) 2006-2013 ARM Limited 10 | * 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 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | #ifndef SINGLETONPTR_H 24 | #define SINGLETONPTR_H 25 | 26 | #include 27 | #include 28 | #include "platform/mbed_assert.h" 29 | #ifdef MBED_CONF_RTOS_PRESENT 30 | #include "cmsis_os2.h" 31 | #endif 32 | 33 | #ifdef MBED_CONF_RTOS_PRESENT 34 | extern osMutexId_t singleton_mutex_id; 35 | #endif 36 | 37 | /** Lock the singleton mutex 38 | * 39 | * This function is typically used to provide 40 | * exclusive access when initializing a 41 | * global object. 42 | */ 43 | inline static void singleton_lock(void) 44 | { 45 | #ifdef MBED_CONF_RTOS_PRESENT 46 | osMutexAcquire(singleton_mutex_id, osWaitForever); 47 | #endif 48 | } 49 | 50 | /** Unlock the singleton mutex 51 | * 52 | * This function is typically used to provide 53 | * exclusive access when initializing a 54 | * global object. 55 | */ 56 | inline static void singleton_unlock(void) 57 | { 58 | #ifdef MBED_CONF_RTOS_PRESENT 59 | osMutexRelease (singleton_mutex_id); 60 | #endif 61 | } 62 | 63 | /** Utility class for creating an using a singleton 64 | * 65 | * @note Synchronization level: Thread safe 66 | * 67 | * @note: This class must only be used in a static context - 68 | * this class must never be allocated or created on the 69 | * stack. 70 | * 71 | * @note: This class is lazily initialized on first use. 72 | * This class is a POD type so if it is not used it will 73 | * be garbage collected. 74 | */ 75 | template 76 | struct SingletonPtr { 77 | 78 | /** Get a pointer to the underlying singleton 79 | * 80 | * @returns 81 | * A pointer to the singleton 82 | */ 83 | T* get() { 84 | if (NULL == _ptr) { 85 | singleton_lock(); 86 | if (NULL == _ptr) { 87 | _ptr = new (_data) T(); 88 | } 89 | singleton_unlock(); 90 | } 91 | // _ptr was not zero initialized or was 92 | // corrupted if this assert is hit 93 | MBED_ASSERT(_ptr == (T *)&_data); 94 | return _ptr; 95 | } 96 | 97 | /** Get a pointer to the underlying singleton 98 | * 99 | * @returns 100 | * A pointer to the singleton 101 | */ 102 | T* operator->() { 103 | return get(); 104 | } 105 | 106 | // This is zero initialized when in global scope 107 | T *_ptr; 108 | // Force data to be 4 byte aligned 109 | uint32_t _data[(sizeof(T) + sizeof(uint32_t) - 1) / sizeof(uint32_t)]; 110 | }; 111 | 112 | #endif 113 | /**@}*/ 114 | 115 | /**@}*/ 116 | -------------------------------------------------------------------------------- /Deployment/Source/KWS/kws.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Arm Limited or its affiliates. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* 20 | * Description: Keyword spotting example code using MFCC feature extraction 21 | * and neural network. 22 | */ 23 | 24 | #include "kws.h" 25 | 26 | KWS::KWS() 27 | { 28 | } 29 | 30 | KWS::~KWS() 31 | { 32 | delete mfcc; 33 | delete mfcc_buffer; 34 | delete output; 35 | delete predictions; 36 | delete averaged_output; 37 | } 38 | 39 | void KWS::init_kws() 40 | { 41 | num_mfcc_features = nn->get_num_mfcc_features(); 42 | num_frames = nn->get_num_frames(); 43 | frame_len = nn->get_frame_len(); 44 | frame_shift = nn->get_frame_shift(); 45 | int mfcc_dec_bits = nn->get_in_dec_bits(); 46 | num_out_classes = nn->get_num_out_classes(); 47 | mfcc = new MFCC(num_mfcc_features, frame_len, mfcc_dec_bits); 48 | mfcc_buffer = new q7_t[num_frames*num_mfcc_features]; 49 | output = new q7_t[num_out_classes]; 50 | averaged_output = new q7_t[num_out_classes]; 51 | predictions = new q7_t[sliding_window_len*num_out_classes]; 52 | audio_block_size = recording_win*frame_shift; 53 | audio_buffer_size = audio_block_size + frame_len - frame_shift; 54 | } 55 | 56 | void KWS::extract_features() 57 | { 58 | if(num_frames>recording_win) { 59 | //move old features left 60 | memmove(mfcc_buffer,mfcc_buffer+(recording_win*num_mfcc_features),(num_frames-recording_win)*num_mfcc_features); 61 | } 62 | //compute features only for the newly recorded audio 63 | int32_t mfcc_buffer_head = (num_frames-recording_win)*num_mfcc_features; 64 | for (uint16_t f = 0; f < recording_win; f++) { 65 | mfcc->mfcc_compute(audio_buffer+(f*frame_shift),&mfcc_buffer[mfcc_buffer_head]); 66 | mfcc_buffer_head += num_mfcc_features; 67 | } 68 | } 69 | 70 | void KWS::classify() 71 | { 72 | nn->run_nn(mfcc_buffer, output); 73 | // Softmax 74 | arm_softmax_q7(output,num_out_classes,output); 75 | } 76 | 77 | int KWS::get_top_class(q7_t* prediction) 78 | { 79 | int max_ind=0; 80 | int max_val=-128; 81 | for(int i=0;i 0.5) { 45 | * printf("Too hot! (%f)", temperature.read()); 46 | * } 47 | * } 48 | * } 49 | * @endcode 50 | * @ingroup drivers 51 | */ 52 | class AnalogIn { 53 | 54 | public: 55 | 56 | /** Create an AnalogIn, connected to the specified pin 57 | * 58 | * @param pin AnalogIn pin to connect to 59 | */ 60 | AnalogIn(PinName pin) { 61 | lock(); 62 | analogin_init(&_adc, pin); 63 | unlock(); 64 | } 65 | 66 | /** Read the input voltage, represented as a float in the range [0.0, 1.0] 67 | * 68 | * @returns A floating-point value representing the current input voltage, measured as a percentage 69 | */ 70 | float read() { 71 | lock(); 72 | float ret = analogin_read(&_adc); 73 | unlock(); 74 | return ret; 75 | } 76 | 77 | /** Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF] 78 | * 79 | * @returns 80 | * 16-bit unsigned short representing the current input voltage, normalised to a 16-bit value 81 | */ 82 | unsigned short read_u16() { 83 | lock(); 84 | unsigned short ret = analogin_read_u16(&_adc); 85 | unlock(); 86 | return ret; 87 | } 88 | 89 | /** An operator shorthand for read() 90 | * 91 | * The float() operator can be used as a shorthand for read() to simplify common code sequences 92 | * 93 | * Example: 94 | * @code 95 | * float x = volume.read(); 96 | * float x = volume; 97 | * 98 | * if(volume.read() > 0.25) { ... } 99 | * if(volume > 0.25) { ... } 100 | * @endcode 101 | */ 102 | operator float() { 103 | // Underlying call is thread safe 104 | return read(); 105 | } 106 | 107 | virtual ~AnalogIn() { 108 | // Do nothing 109 | } 110 | 111 | protected: 112 | 113 | virtual void lock() { 114 | _mutex->lock(); 115 | } 116 | 117 | virtual void unlock() { 118 | _mutex->unlock(); 119 | } 120 | 121 | analogin_t _adc; 122 | static SingletonPtr _mutex; 123 | }; 124 | 125 | } // namespace mbed 126 | 127 | #endif 128 | 129 | #endif 130 | 131 | --------------------------------------------------------------------------------