From c989486a46fab703bc84e4c2e738952e99537a59 Mon Sep 17 00:00:00 2001 From: Kshitij Sisodia Date: Wed, 19 Jun 2024 10:16:55 +0100 Subject: [PATCH] MLECO-4703: Updates for pack versions Alif Semiconductor's Ensemble support updated for the AI/ML AppKit boards. Support for the older revisions of the boards has been dropped as the CMSIS pack versions available don't support these older variants. Most changes are to adapt to the newer pack version. Further changes are required to get the ILI9806E LCD to work correctly. Change-Id: If0a912f3a00685cd7314881c45611cac0ceaf109 Signed-off-by: Kshitij Sisodia --- cmsis-pack-examples/README.md | 33 ++--- cmsis-pack-examples/cdefault.yml | 4 +- cmsis-pack-examples/common/common.clayer.yml | 4 +- .../alif-ensemble-E7-device.clayer.yml | 25 +++- .../alif-ensemble/include/CameraCapture.hpp | 24 ++-- .../alif-ensemble/include/GpioSignal.hpp | 17 ++- .../alif-ensemble/include/LcdDisplay.hpp | 10 +- .../alif-ensemble/src/BoardAudioUtils.cpp | 28 ++-- .../device/alif-ensemble/src/BoardInit.cpp | 133 +++++++++++------- .../alif-ensemble/src/CameraCapture.cpp | 80 +++++++---- .../device/alif-ensemble/src/LcdDisplay.cpp | 50 +++++-- .../src/{gpio.c => gpio_wrapper.c} | 33 ++--- .../src/{gpio.h => gpio_wrapper.h} | 0 .../device/alif-ensemble/src/uart_stdout.c | 100 +++++-------- .../corstone/corstone-device.clayer.yml | 12 +- .../device/corstone/src/BoardInit.cpp | 4 +- .../frdm-k64f/frdm-k64f-device.clayer.yml | 8 +- .../stm32f746-discovery-device.clayer.yml | 4 +- cmsis-pack-examples/kws/kws.cproject.yml | 4 +- .../kws/linker/alif-e7-m55-he.sct | 5 +- cmsis-pack-examples/kws/src/main_live.cpp | 10 +- cmsis-pack-examples/kws/src/main_wav.cpp | 10 +- cmsis-pack-examples/mlek.csolution.yml | 48 ++++--- .../linker/alif-e7-m55-hp.sct | 12 +- .../object-detection.cproject.yml | 4 +- .../object-detection/src/main_live.cpp | 42 +++--- cmsis-pack-examples/vcpkg-configuration.json | 4 +- 27 files changed, 385 insertions(+), 323 deletions(-) rename cmsis-pack-examples/device/alif-ensemble/src/{gpio.c => gpio_wrapper.c} (88%) rename cmsis-pack-examples/device/alif-ensemble/src/{gpio.h => gpio_wrapper.h} (100%) diff --git a/cmsis-pack-examples/README.md b/cmsis-pack-examples/README.md index c241673..2dac267 100644 --- a/cmsis-pack-examples/README.md +++ b/cmsis-pack-examples/README.md @@ -34,13 +34,13 @@ Currently, the following examples are supported: Target platforms supported: -| Name | Type | IP | Examples | -|---------------------|---------------------|-----------------------------------------------|----------| -| Arm® Corstone™-300 | Virtual or physical | Arm® Cortex®-M55 CPU with Arm® Ethos™-U55 or Arm® Ethos™-U65 NPU | All | -| Arm® Corstone™-310 | Virtual or physical | Arm® Cortex®-M85 CPU with Arm® Ethos™-U55 or Arm® Ethos™-U65 NPU | All | -| Alif Ensemble E7 | Physical board | Arm® Cortex®-M55 CPU with Arm® Ethos™-U55 NPU | All | -| STM32F746G-Discovery| Physical board | Arm® Cortex®-M7 CPU | KWS | -| NXP FRDM-K64F | Physical board | Arm® Cortex®-M4 CPU | KWS | +| Name | Type | IP | Examples | +|-----------------------|---------------------|-----------------------------------------------|----------| +| Arm® Corstone™-300 | Virtual or physical | Arm® Cortex®-M55 CPU with Arm® Ethos™-U55 or Arm® Ethos™-U65 NPU | All | +| Arm® Corstone™-310 | Virtual or physical | Arm® Cortex®-M85 CPU with Arm® Ethos™-U55 or Arm® Ethos™-U65 NPU | All | +| Alif™ Ensemble™ E7 AI/ML Kit | Physical board | Arm® Cortex®-M55 CPU with Arm® Ethos™-U55 NPU | All | +| STM32® F746G-Discovery| Physical board | Arm® Cortex®-M7 CPU | KWS | +| NXP® FRDM-K64F | Physical board | Arm® Cortex®-M4 CPU | KWS | Use this import button to open the solution in Keil Studio Cloud: [![Open in Keil Studio](https://img.shields.io/badge/Keil%20Studio-Import-blue?logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyNS40LjEsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCA0NyAxNCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNDcgMTQ7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+DQoJLnN0MHtmaWxsOiNGRkZGRkY7fQ0KPC9zdHlsZT4NCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00LjcsN2MwLDIuMiwxLjQsNC4xLDMuNSw0LjFjMS44LDAsMy42LTEuNCwzLjYtNC4xYzAtMi44LTEuNy00LjItMy42LTQuMkM2LjIsMi45LDQuNyw0LjcsNC43LDcgTTExLjYsMC41DQoJaDIuOXYxM2gtMi45di0xLjNjLTAuOSwxLjEtMi4zLDEuNy0zLjcsMS43QzQsMTMuOSwxLjgsMTAuNiwxLjgsN2MwLTQuMywyLjctNi45LDYuMS02LjljMS41LDAsMi44LDAuNywzLjcsMS45VjAuNXoiLz4NCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik0xOCwwLjVIMjF2MS4yYzAuMy0wLjQsMC43LTAuOCwxLjItMS4xYzAuNS0wLjMsMS4yLTAuNCwxLjctMC40YzAuOCwwLDEuNiwwLjIsMi4zLDAuNmwtMS4yLDIuOA0KCWMtMC40LTAuMy0xLTAuNC0xLjUtMC40Yy0wLjctMC4xLTEuMywwLjItMS44LDAuN0MyMSw0LjYsMjEsNS45LDIxLDYuOHY2LjdIMThWMC41eiIvPg0KPHBhdGggY2xhc3M9InN0MCIgZD0iTTI4LjIsMC41aDIuOXYxLjJjMC43LTAuOSwxLjktMS42LDMuMS0xLjZjMS4zLDAsMi42LDAuNywzLjIsMS45YzAuOS0xLjIsMi4yLTEuOSwzLjctMS45DQoJQzQyLjcsMCw0NCwwLjksNDQuNywyLjJjMC4yLDAuNCwwLjcsMS40LDAuNywzLjN2OC4xaC0yLjlWNi4zYzAtMS41LTAuMi0yLjEtMC4yLTIuM2MtMC4yLTAuNy0wLjktMS4yLTEuNy0xLjENCgljLTAuNywwLTEuMywwLjMtMS43LDAuOWMtMC41LDAuOC0wLjYsMS45LTAuNiwyLjl2Ni43aC0yLjlWNi4zYzAtMS41LTAuMi0yLjEtMC4yLTIuM2MtMC4yLTAuNy0wLjktMS4yLTEuNy0xLjENCgljLTAuNywwLTEuMywwLjMtMS43LDAuOWMtMC41LDAuOC0wLjYsMS45LTAuNiwyLjl2Ni43aC0yLjlMMjguMiwwLjV6Ii8+DQo8L3N2Zz4NCg==&logoWidth=47)](https://studio.keil.arm.com/?import=/~https://github.com/Arm-Examples/mlek-cmsis-pack-examples.git) @@ -224,17 +224,18 @@ Note that most applications will redirect their standard output and error stream Keil Sudio Cloud has an option to open a serial connection that can be used to monitor these streams. -For the Alif Semiconductor's Ensemble DevKit boards, the output over UART is not wired though any -USB. A 1.8V FTDI USART cable is recommended to view the serial output. By default, the high -performance core uses UART device 4, and the high efficiency core uses UART device 2. Check the -board schematic to see which pins these modules use. For the Rev1 version of the board the pins -are: +For the Alif Semiconductor™ Ensemble™ AI/ML kit boards, the output over UART is wired though port +J2 (maked PRG_USB). This port exposes two UARTs - one for SE (Secure Enclave) and the other is +confirable to pass through either UART2 or UART4 using jumpers on J15. For the applications built, +the high performance core uses UART4, and the high efficiency core uses UART2. + +J15 setup is shown below: ``` -UART2 RX_B on J413 pin 13 (P3_16) ↔ FTDI TX -UART2 TX_B on J413 pin 14 (P3_17) ↔ FTDI RX -UART4 RX_B on J412 pin 11 (P3_1) ↔ FTDI TX -UART4 TX_B on J412 pin 12 (P3_2) ↔ FTDI RX +J15-1-3 & 2-4: SE UART +J15-3-5 & 4-6: UART2 +J15-5-7 & 6-8: UART2 +J15-7-9 & 8-10: UART4 ``` For all other targets, serial is available over USB from primary debug/connection port. diff --git a/cmsis-pack-examples/cdefault.yml b/cmsis-pack-examples/cdefault.yml index a9e9e25..9a95e56 100644 --- a/cmsis-pack-examples/cdefault.yml +++ b/cmsis-pack-examples/cdefault.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2023 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2023-2024 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.0.0/tools/projmgr/schemas/cdefault.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.4.0/tools/projmgr/schemas/cdefault.schema.json default: # Note that we need AC6@6.18 or higher to compile for Corstone-310 target. diff --git a/cmsis-pack-examples/common/common.clayer.yml b/cmsis-pack-examples/common/common.clayer.yml index e507b21..ab4c720 100644 --- a/cmsis-pack-examples/common/common.clayer.yml +++ b/cmsis-pack-examples/common/common.clayer.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.0.0/tools/projmgr/schemas/clayer.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.4.0/tools/projmgr/schemas/clayer.schema.json layer: diff --git a/cmsis-pack-examples/device/alif-ensemble/alif-ensemble-E7-device.clayer.yml b/cmsis-pack-examples/device/alif-ensemble/alif-ensemble-E7-device.clayer.yml index e6c71c5..fbb6a84 100644 --- a/cmsis-pack-examples/device/alif-ensemble/alif-ensemble-E7-device.clayer.yml +++ b/cmsis-pack-examples/device/alif-ensemble/alif-ensemble-E7-device.clayer.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2023 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2023-2024 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.0.0/tools/projmgr/schemas/clayer.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.4.0/tools/projmgr/schemas/clayer.schema.json layer: description: Alif Ensemble E7 ML islands' CPU device layer (High-Performance and High-Efficiency Arm Cortex-M55 CPUs). @@ -26,7 +26,8 @@ layer: files: - file: ./src/GpioSignal.cpp - file: ./include/GpioSignal.hpp - - file: ./src/gpio.c + - file: ./src/gpio_wrapper.c + - file: ./src/gpio_wrapper.h - group: AudioHelpers for-context: +Alif-E7-M55-HE @@ -64,11 +65,10 @@ layer: - component: AlifSemiconductor::Device:SOC Peripherals:USART - component: AlifSemiconductor::Device:SOC Peripherals:GPIO - component: AlifSemiconductor::Device:SOC Peripherals:PINCONF + - component: AlifSemiconductor::Device:SOC Peripherals:MHU - component: AlifSemiconductor::Device:Startup - component: ARM::CMSIS Driver:USART - component: ARM::CMSIS Driver:USART:Custom - - component: AlifSemiconductor::Device:SE Services:SE RunTime services&Source - - component: AlifSemiconductor::Device:SE Services:MHU Driver - component: AlifSemiconductor::Device:SOC Peripherals:DMA for-context: +Alif-E7-M55-HE @@ -79,7 +79,7 @@ layer: - component: AlifSemiconductor::Device:SOC Peripherals:I3C for-context: +Alif-E7-M55-HP - - component: AlifSemiconductor::Device:SOC Peripherals:CDC200 + - component: AlifSemiconductor::Device:SOC Peripherals:CDC for-context: +Alif-E7-M55-HP - component: AlifSemiconductor::Device:SOC Peripherals:MIPI CSI2 @@ -88,7 +88,10 @@ layer: - component: AlifSemiconductor::Device:SOC Peripherals:MIPI DSI for-context: +Alif-E7-M55-HP - - component: AlifSemiconductor::Device:SOC Peripherals:CAMERA Controller + - component: AlifSemiconductor::Device:SOC Peripherals:I2C + for-context: +Alif-E7-M55-HP + + - component: AlifSemiconductor::Device:SOC Peripherals:CPI for-context: +Alif-E7-M55-HP - component: AlifSemiconductor::BSP:External peripherals:ILI9806E LCD panel @@ -96,3 +99,11 @@ layer: - component: AlifSemiconductor::BSP:External peripherals:CAMERA Sensor ARX3A0 for-context: +Alif-E7-M55-HP + + - component: AlifSemiconductor::Device:SE runtime Services:core + for-context: +Alif-E7-M55-HP + + - component: AlifSemiconductor::Device:SE runtime Services:Initialization Helper + for-context: +Alif-E7-M55-HP + + diff --git a/cmsis-pack-examples/device/alif-ensemble/include/CameraCapture.hpp b/cmsis-pack-examples/device/alif-ensemble/include/CameraCapture.hpp index eb5364a..ecf4f67 100644 --- a/cmsis-pack-examples/device/alif-ensemble/include/CameraCapture.hpp +++ b/cmsis-pack-examples/device/alif-ensemble/include/CameraCapture.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2023-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -18,18 +18,22 @@ #ifndef CAMERA_CAPTURE_HPP #define CAMERA_CAPTURE_HPP -#if defined (__cplusplus) -extern "C" { - #include "Camera_Common.h" -} -#endif #include +#include "Driver_CPI.h" +#include "RTE_Device.h" + +#if !defined(RTE_ARX3A0_CAMERA_SENSOR_FRAME_WIDTH) || !defined(RTE_ARX3A0_CAMERA_SENSOR_FRAME_HEIGHT) +#error "Camera frame dimensions undefined!" +#endif -#define CAMERA_FRAME_WIDTH 560 -#define CAMERA_FRAME_HEIGHT 560 -#define CAMERA_RESOLUTION CAMERA_RESOLUTION_560x560 +#define CAMERA_FRAME_WIDTH RTE_ARX3A0_CAMERA_SENSOR_FRAME_WIDTH +#define CAMERA_FRAME_HEIGHT RTE_ARX3A0_CAMERA_SENSOR_FRAME_HEIGHT #define CAMERA_IMAGE_RAW_SIZE (CAMERA_FRAME_WIDTH * CAMERA_FRAME_HEIGHT) +#if CAMERA_IMAGE_RAW_SIZE <= 0 +#error "Invalid image size" +#endif + namespace arm { namespace app { @@ -48,7 +52,7 @@ enum class ColourFilter { * @param raw_image Pointer to the raw image that can be populated. * @return int: 0 if successful, error code otherwise */ -int CameraCaptureInit(ARM_CAMERA_RESOLUTION resolution); +int CameraCaptureInit(); /** * @brief Starts the camera capture (does not wait for it to finish) diff --git a/cmsis-pack-examples/device/alif-ensemble/include/GpioSignal.hpp b/cmsis-pack-examples/device/alif-ensemble/include/GpioSignal.hpp index ce7fa50..8ef1572 100644 --- a/cmsis-pack-examples/device/alif-ensemble/include/GpioSignal.hpp +++ b/cmsis-pack-examples/device/alif-ensemble/include/GpioSignal.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -24,7 +24,7 @@ extern "C" { #endif // #if defined(__cplusplus) -#include "gpio.h" +#include "gpio_wrapper.h" #if defined(__cplusplus) } @@ -37,14 +37,17 @@ namespace app { enum class SignalDirection { DirectionOutput = 0, DirectionInput = 1, DirectionInvalid = 2 }; /* Valid GPIO port numbers */ - enum class SignalPort { Port1 = 1, Port2 = 2, Port3 = 3 }; + enum class SignalPort { Port6 = 6, Port7 = 7, Port12 = 12 }; /* Valid and used GPIO pin number definitions */ enum class SignalPin { - Port1_UserButton1 = 12, /* Wired to SW2 on the board. */ - Port3_UserButton2 = 4, /* Wired to SW3 on the board. */ - Port1_StatusLED1 = 14, /* LED1 - green. */ - Port1_StatusLED2 = 15 /* LED2 - orange. */ + Port12_LED0_R = 3, /* LED0 - red. */ + Port07_LED0_G = 4, /* LED0 - green. */ + Port12_LED0_B = 0, /* LED0 - blue. */ + + Port06_LED1_R = 2, /* LED0 - red. */ + Port06_LED1_G = 4, /* LED0 - green. */ + Port06_LED1_B = 6 /* LED0 - blue. */ }; /** diff --git a/cmsis-pack-examples/device/alif-ensemble/include/LcdDisplay.hpp b/cmsis-pack-examples/device/alif-ensemble/include/LcdDisplay.hpp index 402bc0c..bf318a7 100644 --- a/cmsis-pack-examples/device/alif-ensemble/include/LcdDisplay.hpp +++ b/cmsis-pack-examples/device/alif-ensemble/include/LcdDisplay.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -26,6 +26,14 @@ #define DIMAGE_Y RTE_PANEL_VACTIVE_LINE #define RGB_BYTES 3 +#if RTE_CDC200_PIXEL_FORMAT==(1) + #define LCD_BYTES_PER_PIXEL (3) +#elif RTE_CDC200_PIXEL_FORMAT==(2) + #define LCD_BYTES_PER_PIXEL (2) +#else // LCD_BYTES_PER_PIXEL + #error "Unsupported RTE_CDC200_PIXEL_FORMAT." +#endif // LCD_BYTES_PER_PIXEL + namespace arm { namespace app { diff --git a/cmsis-pack-examples/device/alif-ensemble/src/BoardAudioUtils.cpp b/cmsis-pack-examples/device/alif-ensemble/src/BoardAudioUtils.cpp index 3cbce1b..2aca9e0 100644 --- a/cmsis-pack-examples/device/alif-ensemble/src/BoardAudioUtils.cpp +++ b/cmsis-pack-examples/device/alif-ensemble/src/BoardAudioUtils.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2023-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -26,13 +26,13 @@ extern "C" { #include "RTE_Components.h" #include "RTE_Device.h" -#include +#include "pinconf.h" #include #include CMSIS_device_header #include -#define I2S_ADC 2 /* Audio I2S Controller 2 */ +#define I2S_ADC 3 /* Audio I2S Controller 3 */ extern ARM_DRIVER_SAI ARM_Driver_SAI_(I2S_ADC); ARM_DRIVER_SAI* s_i2s_drv; @@ -45,9 +45,9 @@ static volatile audio_capture_state s_cap_state; static void set_capture_completed(bool val) { - NVIC_DisableIRQ((IRQn_Type)I2S2_IRQ); + NVIC_DisableIRQ((IRQn_Type)I2S3_IRQ_IRQn); s_cap_state.capCompleted = val; - NVIC_EnableIRQ((IRQn_Type)I2S2_IRQ); + NVIC_EnableIRQ((IRQn_Type)I2S3_IRQ_IRQn); } static void set_capture_started(bool val) @@ -77,20 +77,14 @@ static int32_t ConfigureI2SPinMuxPinPad() { int32_t status = 0; - // Configure P2_1.I2S2_SDI_A - status |= PINMUX_Config(PORT_NUMBER_2, PIN_NUMBER_1, PINMUX_ALTERNATE_FUNCTION_3); - status |= - PINPAD_Config(PORT_NUMBER_2, - PIN_NUMBER_1, - PAD_FUNCTION_DRIVER_DISABLE_STATE_WITH_PULL_DOWN | PAD_FUNCTION_READ_ENABLE); + /** Configure I2S3_B_WS */ + status |= pinconf_set(PORT_8, PIN_7, PINMUX_ALTERNATE_FUNCTION_2, 0); - /* Configure P2_3.I2S2_SCLK_A */ - status |= PINMUX_Config(PORT_NUMBER_2, PIN_NUMBER_3, PINMUX_ALTERNATE_FUNCTION_3); - status |= PINPAD_Config(PORT_NUMBER_2, PIN_NUMBER_3, PAD_FUNCTION_READ_ENABLE); + /** Configure I2S3_B_SCLK */ + status |= pinconf_set(PORT_8, PIN_6, PINMUX_ALTERNATE_FUNCTION_2, 0); - /* Configure P2_3.I2S2_WS_A */ - status |= PINMUX_Config(PORT_NUMBER_2, PIN_NUMBER_4, PINMUX_ALTERNATE_FUNCTION_2); - status |= PINPAD_Config(PORT_NUMBER_2, PIN_NUMBER_4, PAD_FUNCTION_READ_ENABLE); + /** Configure I2S3_B_SDI */ + status |= pinconf_set(PORT_9, PIN_0, PINMUX_ALTERNATE_FUNCTION_2, PADCTRL_READ_ENABLE); return status; } diff --git a/cmsis-pack-examples/device/alif-ensemble/src/BoardInit.cpp b/cmsis-pack-examples/device/alif-ensemble/src/BoardInit.cpp index 94183b9..418a6de 100644 --- a/cmsis-pack-examples/device/alif-ensemble/src/BoardInit.cpp +++ b/cmsis-pack-examples/device/alif-ensemble/src/BoardInit.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2023-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -25,12 +25,17 @@ extern "C" { #include "RTE_Components.h" #include "RTE_Device.h" #include CMSIS_device_header -#include "Driver_PINMUX_AND_PINPAD.h" +#include "pinconf.h" #include "Driver_Common.h" #include "ethosu_driver.h" #include "uart_stdout.h" +#include "log_macros.h" #include +#if defined(M55_HP) +#include "se_services_port.h" +#endif /* defined(M55_HP) */ + static struct ethosu_driver npuDriver; static void npu_irq_handler(void) { @@ -43,9 +48,7 @@ static void npu_irq_handler(void) bool NpuInit() { - /* Base address is 0x4000E1000; interrupt number is 55. */ - constexpr uint32_t npuBaseOffset = 0xE1000; - const void *npuBaseAddr = reinterpret_cast(LOCAL_PERIPHERAL_BASE + npuBaseOffset); + void * const npuBaseAddr = reinterpret_cast(LOCAL_NPU_BASE); /* Initialize Ethos-U NPU driver. */ if (ethosu_init(&npuDriver, /* Arm Ethos-U device driver pointer */ @@ -58,8 +61,8 @@ bool NpuInit() return false; } - NVIC_SetVector(NPU_IRQ, (uint32_t) &npu_irq_handler); - NVIC_EnableIRQ(NPU_IRQ); + NVIC_SetVector(LOCAL_NPU_IRQ_IRQn, (uint32_t) &npu_irq_handler); + NVIC_EnableIRQ(LOCAL_NPU_IRQ_IRQn); return true; } @@ -82,63 +85,86 @@ static void CpuCacheEnable(void) static int I3CPinsInit(void) { - /* Configure GPIO Pin : P3_8 as I3C_SDA_B */ - int ret = PINMUX_Config(PORT_NUMBER_3, PIN_NUMBER_8, PINMUX_ALTERNATE_FUNCTION_3); - if(ret != ARM_DRIVER_OK) { - return ret; - } + int ret = pinconf_set(PORT_7, PIN_2, + PINMUX_ALTERNATE_FUNCTION_5, + PADCTRL_READ_ENABLE | PADCTRL_DRIVER_DISABLED_PULL_UP); - /* Configure GPIO Pin : P3_9 as I3C_SCL_B */ - ret = PINMUX_Config(PORT_NUMBER_3, PIN_NUMBER_9, PINMUX_ALTERNATE_FUNCTION_4); - if(ret != ARM_DRIVER_OK) { + if (ret != ARM_DRIVER_OK) { return ret; } - /* Pin-Pad P3_8 as I3C_SDA_B - * Pad function: PAD_FUNCTION_READ_ENABLE | - * PAD_FUNCTION_DRIVER_DISABLE_STATE_WITH_PULL_UP | - * PAD_FUNCTION_DRIVER_OPEN_DRAIN - */ - ret = PINPAD_Config(PORT_NUMBER_3, PIN_NUMBER_8, PAD_FUNCTION_READ_ENABLE | - PAD_FUNCTION_DRIVER_DISABLE_STATE_WITH_PULL_UP | - PAD_FUNCTION_DRIVER_OPEN_DRAIN); - if(ret != ARM_DRIVER_OK) { - return ret; - } - - /* Pin-Pad P3_9 as I3C_SCL_B - * Pad function: PAD_FUNCTION_READ_ENABLE | - * PAD_FUNCTION_DRIVER_DISABLE_STATE_WITH_PULL_UP | - * PAD_FUNCTION_DRIVER_OPEN_DRAIN - */ - ret = PINPAD_Config(PORT_NUMBER_3, PIN_NUMBER_9,PAD_FUNCTION_READ_ENABLE | - PAD_FUNCTION_DRIVER_DISABLE_STATE_WITH_PULL_UP | - PAD_FUNCTION_DRIVER_OPEN_DRAIN); - if(ret != ARM_DRIVER_OK) { - return ret; - } + ret = pinconf_set(PORT_7, PIN_3, + PINMUX_ALTERNATE_FUNCTION_5, + PADCTRL_READ_ENABLE | PADCTRL_DRIVER_DISABLED_PULL_UP); - return 0; + return ret; } static int CameraPinsInit(void) { - /* @Note: Below GPIO pins are configured for Camera. - * - * For ASIC A1 CPU Board - * - P2_7 as CAM_XVCLK_B - */ -#if RTE_SILICON_REV_A1 + return pinconf_set(PORT_0, PIN_3, PINMUX_ALTERNATE_FUNCTION_6, 0); +} - /* Configure GPIO Pin : P2_7 as CAM_XVCLK_B */ - int ret = PINMUX_Config(PORT_NUMBER_2, PIN_NUMBER_7, PINMUX_ALTERNATE_FUNCTION_6); +static uint32_t CameraClocksEnable(void) +{ + uint32_t error_code = SERVICES_REQ_SUCCESS; + uint32_t service_error_code; + run_profile_t runp = {0}; + + /* Initialize the SE services */ + se_services_port_init(); + + /* Enable MIPI Clocks */ + error_code = SERVICES_clocks_enable_clock(se_services_s_handle, CLKEN_CLK_100M, true, &service_error_code); + if(error_code != SERVICES_REQ_SUCCESS) { + printf_err("SE: MIPI 100MHz clock enable = %d\n", error_code); + return error_code; + } - if(ret != ARM_DRIVER_OK) { - return ret; + error_code = SERVICES_clocks_enable_clock(se_services_s_handle, CLKEN_HFOSC, true, &service_error_code); + if(error_code != SERVICES_REQ_SUCCESS) { + printf_err("SE: MIPI 38.4Mhz(HFOSC) clock enable = %d\n", error_code); + goto error_disable_100mhz_clk; + } + + /* Get the current run configuration from SE */ + error_code = SERVICES_get_run_cfg(se_services_s_handle, + &runp, + &service_error_code); + if (error_code != SERVICES_REQ_SUCCESS) { + printf_err("\r\nSE: get_run_cfg error = %d\n", error_code); + goto error_disable_hfosc_clk; } -#endif /* RTE_SILICON_REV_A1 */ + runp.memory_blocks = MRAM_MASK | SRAM0_MASK | SRAM1_MASK; + + runp.phy_pwr_gating = MIPI_PLL_DPHY_MASK | MIPI_TX_DPHY_MASK | MIPI_RX_DPHY_MASK | LDO_PHY_MASK; + + /* Set the new run configuration */ + error_code = SERVICES_set_run_cfg(se_services_s_handle, + &runp, + &service_error_code); + if(error_code) { + printf_err("\r\nSE: set_run_cfg error = %d\n", error_code); + goto error_disable_hfosc_clk; + } + + info("Camera clocks enabled.\n"); return 0; + +error_disable_hfosc_clk: + error_code = SERVICES_clocks_enable_clock(se_services_s_handle, CLKEN_HFOSC, false, &service_error_code); + if (error_code != SERVICES_REQ_SUCCESS) { + printf_err("SE: MIPI 38.4Mhz(HFOSC) clock disable = %d\n", error_code); + } + +error_disable_100mhz_clk: + error_code = SERVICES_clocks_enable_clock(se_services_s_handle, CLKEN_CLK_100M, false, &service_error_code); + if (error_code != SERVICES_REQ_SUCCESS) { + printf_err("SE: MIPI 100MHz clock disable = %d\n", error_code); + } + + return 1; } #endif /* defined (M55_HP) */ @@ -159,6 +185,11 @@ void BoardInit(void) printf("CameraPinsInit failed\n"); return; } + + if (0 != CameraClocksEnable()) { + printf("CameraClocksEnable failed\n"); + return; + } #endif /* defined (M55_HP) */ #if defined(ETHOSU_ARCH) && (ETHOSU_ARCH==u55) @@ -169,5 +200,7 @@ void BoardInit(void) /* Enable the CPU Cache */ CpuCacheEnable(); + + printf("Board init: completed\n"); return; } diff --git a/cmsis-pack-examples/device/alif-ensemble/src/CameraCapture.cpp b/cmsis-pack-examples/device/alif-ensemble/src/CameraCapture.cpp index 4bab374..0af206f 100644 --- a/cmsis-pack-examples/device/alif-ensemble/src/CameraCapture.cpp +++ b/cmsis-pack-examples/device/alif-ensemble/src/CameraCapture.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2023-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -37,35 +37,34 @@ extern "C" { #include "RTE_Components.h" #include CMSIS_device_header -#include "Driver_Camera_Controller.h" -#include "Driver_Common.h" +#include "Driver_CPI.h" #include "Driver_GPIO.h" -#include "Driver_PINMUX_AND_PINPAD.h" +#include "pinconf.h" #include "log_macros.h" -extern ARM_DRIVER_GPIO Driver_GPIO1; -extern ARM_DRIVER_CAMERA_CONTROLLER Driver_CAMERA0; +extern ARM_DRIVER_CPI Driver_CPI; static struct arm_camera_status { bool frame_complete: 1; bool camera_error: 1; } camera_status; +#define CPI_CAMERA_ERR_MASK (ARM_CPI_EVENT_ERR_HARDWARE | \ + ARM_CPI_EVENT_MIPI_CSI2_ERROR | \ + ARM_CPI_EVENT_ERR_CAMERA_OUTPUT_FIFO_OVERRUN | \ + ARM_CPI_EVENT_ERR_CAMERA_INPUT_FIFO_OVERRUN) + +#define CPI_FRAME_DONE_MASK (ARM_CPI_EVENT_CAMERA_CAPTURE_STOPPED) + +#define CPI_ALL_EVENTS_MASK (CPI_CAMERA_ERR_MASK | CPI_FRAME_DONE_MASK) + static void camera_event_cb(uint32_t event) { - if(event & ARM_CAMERA_CONTROLLER_EVENT_CAMERA_FRAME_VSYNC_DETECTED) { + if(event & CPI_FRAME_DONE_MASK ) { camera_status.frame_complete = true; } - if(event & ARM_CAMERA_CONTROLLER_EVENT_ERR_CAMERA_FIFO_OVERRUN) { - camera_status.camera_error = true; - } - - if(event & ARM_CAMERA_CONTROLLER_EVENT_ERR_CAMERA_FIFO_UNDERRUN) { - camera_status.camera_error = true; - } - - if(event & ARM_CAMERA_CONTROLLER_EVENT_MIPI_CSI2_ERROR) { + if(event & CPI_CAMERA_ERR_MASK) { camera_status.camera_error = true; } } @@ -78,38 +77,50 @@ __attribute__((noreturn)) static void CameraErrorLoop(const char* errorStr) { printf_err("%s\n", errorStr); while(true) { - Driver_GPIO1.SetValue(PIN_NUMBER_14, GPIO_PIN_OUTPUT_STATE_LOW); - PMU_delay_loop_us(300000); - Driver_GPIO1.SetValue(PIN_NUMBER_14, GPIO_PIN_OUTPUT_STATE_HIGH); - PMU_delay_loop_us(300000); + __WFI(); } } -int arm::app::CameraCaptureInit(ARM_CAMERA_RESOLUTION resolution) +int arm::app::CameraCaptureInit() { - if (0 != Driver_CAMERA0.Initialize(resolution, camera_event_cb)) { + int32_t ret = ARM_DRIVER_ERROR; + + if (ARM_DRIVER_OK != (ret = Driver_CPI.Initialize(camera_event_cb))) { CameraErrorLoop("Camera initialisation failed.\n"); + return ret; } - if (0 != Driver_CAMERA0.PowerControl(ARM_POWER_FULL)) { + if (ARM_DRIVER_OK != (ret = Driver_CPI.PowerControl(ARM_POWER_FULL))) { CameraErrorLoop("Camera power up failed.\n"); + return ret; } - if (0 != Driver_CAMERA0.Control(CAMERA_SENSOR_CONFIGURE, resolution)) { + if (ARM_DRIVER_OK != (ret = Driver_CPI.Control(CPI_CONFIGURE, 0))) { CameraErrorLoop("Camera configuration failed.\n"); + return ret; + } + + if (ARM_DRIVER_OK != (ret = Driver_CPI.Control(CPI_CAMERA_SENSOR_CONFIGURE, 0))) { + CameraErrorLoop("Camera configuration failed.\n"); + return ret; + } + + if (ARM_DRIVER_OK != (ret = Driver_CPI.Control(CPI_EVENTS_CONFIGURE, CPI_ALL_EVENTS_MASK))) { + CameraErrorLoop("Camera configuration failed.\n"); + return ret; } info("Camera initialised.\n"); - Driver_GPIO1.SetValue(PIN_NUMBER_14, GPIO_PIN_OUTPUT_STATE_HIGH); - return 0; + return ret; } static inline void CameraStatusReset() { - NVIC_DisableIRQ((IRQn_Type) CAMERA0_IRQ); + NVIC_DisableIRQ((IRQn_Type) CAM_IRQ_IRQn); camera_status.frame_complete = false; camera_status.camera_error = false; - NVIC_EnableIRQ((IRQn_Type) CAMERA0_IRQ); + NVIC_ClearPendingIRQ((IRQn_Type) CAM_IRQ_IRQn); + NVIC_EnableIRQ((IRQn_Type) CAM_IRQ_IRQn); } int arm::app::CameraCaptureStart(uint8_t* rawImage) @@ -118,19 +129,26 @@ int arm::app::CameraCaptureStart(uint8_t* rawImage) /* NOTE: This is a blocking call at the moment; doesn't need to be. * It slows down the whole pipeline considerably. */ - Driver_CAMERA0.CaptureFrame(rawImage); - return 0; + return Driver_CPI.CaptureFrame(rawImage); } void arm::app::CameraCaptureWaitForFrame() { - while (camera_status.frame_complete != true) { + trace("Waiting for camera frame\n"); + while (!camera_status.frame_complete && !camera_status.camera_error) { __WFI(); } + if (camera_status.frame_complete) { + trace("Frame complete signal received\n"); + } + if (camera_status.camera_error) { printf_err("Camera error detected!\n"); + Driver_CPI.Stop(); } + + CameraStatusReset(); } /** diff --git a/cmsis-pack-examples/device/alif-ensemble/src/LcdDisplay.cpp b/cmsis-pack-examples/device/alif-ensemble/src/LcdDisplay.cpp index 977e971..083104b 100644 --- a/cmsis-pack-examples/device/alif-ensemble/src/LcdDisplay.cpp +++ b/cmsis-pack-examples/device/alif-ensemble/src/LcdDisplay.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -57,9 +57,9 @@ static void cdc_event_handler(uint32_t event) static void clear_display_error(void) { /* Clear the error. */ - NVIC_DisableIRQ((IRQn_Type)MIPI_DSI_IRQ); + NVIC_DisableIRQ((IRQn_Type)DSI_IRQ_IRQn); s_display_error = false; - NVIC_EnableIRQ((IRQn_Type)MIPI_DSI_IRQ); + NVIC_EnableIRQ((IRQn_Type)DSI_IRQ_IRQn); } #if defined(__cplusplus) @@ -176,8 +176,8 @@ namespace app { lcd_params.buffer = lcdImageBuffer; lcd_params.height = lcdHeight; lcd_params.width = lcdWidth; - lcd_params.bytes_per_pixel = RGB_BYTES; - lcd_params.bytes = lcdHeight * lcdWidth * RGB_BYTES; + lcd_params.bytes_per_pixel = LCD_BYTES_PER_PIXEL; + lcd_params.bytes = lcdHeight * lcdWidth * lcd_params.bytes_per_pixel; return true; } @@ -201,9 +201,7 @@ namespace app { (lcd_params.width * lcd_params.bytes_per_pixel * rowOffset) + (colOffset * lcd_params.bytes_per_pixel); - for (uint32_t point = 0; point < width * RGB_BYTES; point++) { - lcdPtr[point] = 0; - } + std::memset(lcdPtr, 0, width * lcd_params.bytes_per_pixel); } if (s_display_error) { printf_err("Display error detected\n"); @@ -212,6 +210,24 @@ namespace app { return true; } + static inline void RGB888ToRGB565(const uint8_t* rgb888, uint8_t* rgb565) + { + uint16_t* dst = reinterpret_cast(rgb565); + *dst = __REV16( + (((rgb888[0] >> 3) & 0x1f) << 11) | /* Red */ + (((rgb888[1] >> 2) & 0x3f) << 5) | /* Green */ + (((rgb888[2] >> 3) & 0x1f) << 0)); /* Blue */ + } + + static inline void BGR888ToRGB565(const uint8_t* bgr888, uint8_t* rgb565) + { + uint16_t* dst = reinterpret_cast(rgb565); + *dst = __REV16( + (((bgr888[2] >> 3) & 0x1f) << 11) | /* Red */ + (((bgr888[1] >> 2) & 0x3f) << 5) | /* Green */ + (((bgr888[0] >> 3) & 0x1f) << 0)); /* Blue */ + } + bool LcdDisplayImage( const uint8_t* rgbData, uint32_t rgbWidth, @@ -237,12 +253,12 @@ namespace app { uint8_t* lcdPtr = lcd_params.buffer + (lcd_params.width * lcd_params.bytes_per_pixel * rowLcd) + (lcdColOffset * lcd_params.bytes_per_pixel); - const uint8_t* rgb_ptr = rgbData + (rgbWidth * RGB_BYTES * rowRgb); + const uint8_t* rgbPtr = rgbData + (rgbWidth * RGB_BYTES * rowRgb); - for (colRgb = 0; colRgb < rgbWidth * RGB_BYTES; colRgb += 3, lcdPtr += 3) { - lcdPtr[2] = *rgb_ptr++; - lcdPtr[1] = *rgb_ptr++; - lcdPtr[0] = *rgb_ptr++; + for (colRgb = 0; colRgb < rgbWidth; ++colRgb) { + BGR888ToRGB565(rgbPtr, lcdPtr); + lcdPtr += lcd_params.bytes_per_pixel; + rgbPtr += RGB_BYTES; } } } else if (rgbFormat == ColourFormat::RGB) { @@ -250,9 +266,13 @@ namespace app { uint8_t* lcdPtr = lcd_params.buffer + (lcd_params.width * lcd_params.bytes_per_pixel * rowLcd) + (lcdColOffset * lcd_params.bytes_per_pixel); - const uint8_t* rgb_ptr = rgbData + (rgbWidth * RGB_BYTES * rowRgb); + const uint8_t* rgbPtr = rgbData + (rgbWidth * RGB_BYTES * rowRgb); - memcpy(lcdPtr, rgb_ptr, rgbWidth * RGB_BYTES); + for (colRgb = 0; colRgb < rgbWidth; ++colRgb) { + RGB888ToRGB565(rgbPtr, lcdPtr); + lcdPtr += lcd_params.bytes_per_pixel; + rgbPtr += RGB_BYTES; + } } } else { printf_err("Unsupported format\n"); diff --git a/cmsis-pack-examples/device/alif-ensemble/src/gpio.c b/cmsis-pack-examples/device/alif-ensemble/src/gpio_wrapper.c similarity index 88% rename from cmsis-pack-examples/device/alif-ensemble/src/gpio.c rename to cmsis-pack-examples/device/alif-ensemble/src/gpio_wrapper.c index 4117e5d..0bd4bf4 100644 --- a/cmsis-pack-examples/device/alif-ensemble/src/gpio.c +++ b/cmsis-pack-examples/device/alif-ensemble/src/gpio_wrapper.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -20,38 +20,39 @@ extern "C" { #endif -#include "gpio.h" +#include "gpio_wrapper.h" #include "RTE_Components.h" #include "RTE_Device.h" #include CMSIS_device_header #include "Driver_GPIO.h" -#include "Driver_PINMUX_AND_PINPAD.h" #include "log_macros.h" -extern ARM_DRIVER_GPIO Driver_GPIO1; -extern ARM_DRIVER_GPIO Driver_GPIO2; -extern ARM_DRIVER_GPIO Driver_GPIO3; +extern ARM_DRIVER_GPIO Driver_GPIO6; +extern ARM_DRIVER_GPIO Driver_GPIO7; +extern ARM_DRIVER_GPIO Driver_GPIO12; static bool is_gpio_port_valid(uint8_t gpio_port) { - if (gpio_port < 1 || gpio_port > 3) { - printf_err("Invalid GPIO port # %d\n", gpio_port); - return false; + switch (gpio_port) { + case 6: return true; + case 7: return true; + case 12: return true; + default: printf_err("Invalid GPIO port # %d\n", gpio_port); } - return true; + return false; } static ARM_DRIVER_GPIO* get_driver(uint8_t port) { switch (port) { - case 1: - return &Driver_GPIO1; - case 2: - return &Driver_GPIO2; - case 3: - return &Driver_GPIO3; + case 6: + return &Driver_GPIO6; + case 7: + return &Driver_GPIO7; + case 12: + return &Driver_GPIO12; default: break; } diff --git a/cmsis-pack-examples/device/alif-ensemble/src/gpio.h b/cmsis-pack-examples/device/alif-ensemble/src/gpio_wrapper.h similarity index 100% rename from cmsis-pack-examples/device/alif-ensemble/src/gpio.h rename to cmsis-pack-examples/device/alif-ensemble/src/gpio_wrapper.h diff --git a/cmsis-pack-examples/device/alif-ensemble/src/uart_stdout.c b/cmsis-pack-examples/device/alif-ensemble/src/uart_stdout.c index 58022cb..2d1ea29 100644 --- a/cmsis-pack-examples/device/alif-ensemble/src/uart_stdout.c +++ b/cmsis-pack-examples/device/alif-ensemble/src/uart_stdout.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -16,7 +16,7 @@ * limitations under the License. */ #include "uart_stdout.h" -#include "Driver_PINMUX_AND_PINPAD.h" +#include "pinconf.h" #include "Driver_USART.h" #include @@ -50,6 +50,33 @@ extern ARM_DRIVER_USART USART_Driver_(USART_DRV_NUM); #define ptrUSART (&USART_Driver_(USART_DRV_NUM)) +#if USART_DRV_NUM == 1 + #define PORT_NUM PORT_0 + #define RX_PIN PIN_4 + #define TX_PIN PIN_5 + #define RX_PINMUX_FUNCTION PINMUX_ALTERNATE_FUNCTION_2 + #define TX_PINMUX_FUNCTION PINMUX_ALTERNATE_FUNCTION_2 + #define RX_PADCTRL PADCTRL_READ_ENABLE + #define TX_PADCTRL 0 +#elif USART_DRV_NUM == 2 + #define PORT_NUM PORT_1 + #define RX_PIN PIN_0 + #define TX_PIN PIN_1 + #define RX_PINMUX_FUNCTION PINMUX_ALTERNATE_FUNCTION_1 + #define TX_PINMUX_FUNCTION PINMUX_ALTERNATE_FUNCTION_1 + #define RX_PADCTRL PADCTRL_READ_ENABLE + #define TX_PADCTRL 0 +#elif USART_DRV_NUM == 4 + #define PORT_NUM PORT_12 + #define RX_PIN PIN_1 + #define TX_PIN PIN_2 + #define RX_PINMUX_FUNCTION PINMUX_ALTERNATE_FUNCTION_2 + #define TX_PINMUX_FUNCTION PINMUX_ALTERNATE_FUNCTION_2 + #define RX_PADCTRL PADCTRL_READ_ENABLE + #define TX_PADCTRL 0 +#else /* USART_DRV_NUM */ +#endif /* USART_DRV_NUM */ + /** Initialize pinmux @@ -57,74 +84,11 @@ extern ARM_DRIVER_USART USART_Driver_(USART_DRV_NUM); */ static int usart_pinmux_init(void) { - int32_t ret; - uint32_t port_config = PAD_FUNCTION_READ_ENABLE | - PAD_FUNCTION_DRIVER_DISABLE_STATE_WITH_PULL_UP; - -#if USART_DRV_NUM == 1 /* Rev A0 - DevKit Alpha */ - /* PINMUX UART1_A */ - /* Configure GPIO Pin : P1_4 as UART1_RX_A */ - ret = PINMUX_Config (PORT_NUMBER_1, PIN_NUMBER_4, PINMUX_ALTERNATE_FUNCTION_1); - if(ret != ARM_DRIVER_OK) { - return ret; - } - ret = PINPAD_Config(PORT_NUMBER_1, PIN_NUMBER_4, port_config); - if(ret != ARM_DRIVER_OK) { - return ret; - } + int32_t ret = pinconf_set(PORT_NUM, TX_PIN, TX_PINMUX_FUNCTION, TX_PADCTRL); - /* Configure GPIO Pin : P1_5 as UART1_TX_A */ - ret = PINMUX_Config (PORT_NUMBER_1, PIN_NUMBER_5, PINMUX_ALTERNATE_FUNCTION_1); - if(ret != ARM_DRIVER_OK) { - return ret; - } - ret = PINPAD_Config(PORT_NUMBER_1, PIN_NUMBER_5, port_config); - if(ret != ARM_DRIVER_OK) { - return ret; - } -#elif USART_DRV_NUM == 2 /* Rev A1 - DevKit Beta */ - /* PINMUX UART2_B */ - /* Configure GPIO Pin : P3_16 as UART2_RX_B */ - ret = PINMUX_Config (PORT_NUMBER_3, PIN_NUMBER_16, PINMUX_ALTERNATE_FUNCTION_2); - if(ret != ARM_DRIVER_OK) { - return ret; - } - ret = PINPAD_Config(PORT_NUMBER_3, PIN_NUMBER_16, port_config); - if(ret != ARM_DRIVER_OK) { - return ret; - } - - /* Configure GPIO Pin : P3_17 as UART2_TX_B */ - ret = PINMUX_Config (PORT_NUMBER_3, PIN_NUMBER_17, PINMUX_ALTERNATE_FUNCTION_2); - if(ret != ARM_DRIVER_OK) { - return ret; - } - ret = PINPAD_Config(PORT_NUMBER_3, PIN_NUMBER_17, port_config); - if(ret != ARM_DRIVER_OK) { - return ret; - } -#elif USART_DRV_NUM == 4 /* Rev A1 - DevKit Beta */ - /* PINMUX UART4_B */ - /* Configure GPIO Pin : P3_1 as UART4_RX_B */ - ret = PINMUX_Config (PORT_NUMBER_3, PIN_NUMBER_1, PINMUX_ALTERNATE_FUNCTION_1); - if(ret != ARM_DRIVER_OK) { - return ret; - } - ret = PINPAD_Config(PORT_NUMBER_3, PIN_NUMBER_1, port_config); - if(ret != ARM_DRIVER_OK) { - return ret; - } - - /* Configure GPIO Pin : P3_2 as UART4_TX_B */ - ret = PINMUX_Config (PORT_NUMBER_3, PIN_NUMBER_2, PINMUX_ALTERNATE_FUNCTION_1); - if(ret != ARM_DRIVER_OK) { - return ret; - } - ret = PINPAD_Config(PORT_NUMBER_3, PIN_NUMBER_2, port_config); - if(ret != ARM_DRIVER_OK) { - return ret; + if (ARM_DRIVER_OK == ret) { + ret = pinconf_set(PORT_NUM, RX_PIN, RX_PINMUX_FUNCTION, RX_PADCTRL); } -#endif return ret; } diff --git a/cmsis-pack-examples/device/corstone/corstone-device.clayer.yml b/cmsis-pack-examples/device/corstone/corstone-device.clayer.yml index ed256b0..804b633 100644 --- a/cmsis-pack-examples/device/corstone/corstone-device.clayer.yml +++ b/cmsis-pack-examples/device/corstone/corstone-device.clayer.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.0.0/tools/projmgr/schemas/clayer.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.4.0/tools/projmgr/schemas/clayer.schema.json layer: @@ -39,10 +39,10 @@ layer: components: - component: ARM::Device:Definition - - component: ARM::Device:Startup&Baremetal - - component: ARM::Native Driver:Timeout - - component: ARM::Native Driver:SysCounter - - component: ARM::Native Driver:SysTimer + - component: ARM::Device:Startup&C Startup + - component: ARM::Device:Native Driver:Timeout + - component: ARM::Device:Native Driver:SysCounter + - component: ARM::Device:Native Driver:SysTimer - component: Arm::Machine Learning:NPU Support:Ethos-U Driver&Generic U55 for-context: - +AVH-SSE-300-U55 diff --git a/cmsis-pack-examples/device/corstone/src/BoardInit.cpp b/cmsis-pack-examples/device/corstone/src/BoardInit.cpp index f41ea22..5022383 100644 --- a/cmsis-pack-examples/device/corstone/src/BoardInit.cpp +++ b/cmsis-pack-examples/device/corstone/src/BoardInit.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -87,7 +87,7 @@ static int arm_ethosu_npu_init(void) arm_ethosu_npu_irq_init(); /* Initialise Ethos-U device */ - const void* ethosu_base_address = (void*)(ETHOS_U55_APB_BASE_S); + void* const ethosu_base_address = (void*)(ETHOS_U55_APB_BASE_S); debug("Cache arena: 0x%p\n", get_cache_arena()); diff --git a/cmsis-pack-examples/device/frdm-k64f/frdm-k64f-device.clayer.yml b/cmsis-pack-examples/device/frdm-k64f/frdm-k64f-device.clayer.yml index be11c59..bf2178b 100644 --- a/cmsis-pack-examples/device/frdm-k64f/frdm-k64f-device.clayer.yml +++ b/cmsis-pack-examples/device/frdm-k64f/frdm-k64f-device.clayer.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.0.0/tools/projmgr/schemas/clayer.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.4.0/tools/projmgr/schemas/clayer.schema.json layer: @@ -25,10 +25,10 @@ layer: for-context: - +FRDM-K64F files: - - file: src/retarget.c + - file: src/uart_stdout.h - file: src/uart_stdout.c + - file: src/retarget.c - file: src/BoardInit.cpp - - file: include/uart_stdout.h - file: include/BoardInit.hpp components: diff --git a/cmsis-pack-examples/device/stm32f746-discovery/stm32f746-discovery-device.clayer.yml b/cmsis-pack-examples/device/stm32f746-discovery/stm32f746-discovery-device.clayer.yml index 47721c1..0031f73 100644 --- a/cmsis-pack-examples/device/stm32f746-discovery/stm32f746-discovery-device.clayer.yml +++ b/cmsis-pack-examples/device/stm32f746-discovery/stm32f746-discovery-device.clayer.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.0.0/tools/projmgr/schemas/clayer.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.4.0/tools/projmgr/schemas/clayer.schema.json layer: diff --git a/cmsis-pack-examples/kws/kws.cproject.yml b/cmsis-pack-examples/kws/kws.cproject.yml index 74aa46e..be73dbf 100644 --- a/cmsis-pack-examples/kws/kws.cproject.yml +++ b/cmsis-pack-examples/kws/kws.cproject.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.0.0/tools/projmgr/schemas/cproject.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.4.0/tools/projmgr/schemas/cproject.schema.json project: output: diff --git a/cmsis-pack-examples/kws/linker/alif-e7-m55-he.sct b/cmsis-pack-examples/kws/linker/alif-e7-m55-he.sct index 329c183..3c2b83c 100644 --- a/cmsis-pack-examples/kws/linker/alif-e7-m55-he.sct +++ b/cmsis-pack-examples/kws/linker/alif-e7-m55-he.sct @@ -1,8 +1,9 @@ #! armclang -E --target=arm-arm-none-eabi -mcpu=cortex-m55 -xc ; command above MUST be in first line (no comment above!) -#include "../../device/alif-ensemble/RTE/Device/AE722F80F55D5TE_M55_HE/M55_HE_map.h" +#include "../../device/alif-ensemble/RTE/Device/AE722F80F55D5LS_M55_HE/M55_HE_map.h" -; SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its + +; SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its ; affiliates ; SPDX-License-Identifier: Apache-2.0 ; diff --git a/cmsis-pack-examples/kws/src/main_live.cpp b/cmsis-pack-examples/kws/src/main_live.cpp index 54bb578..98a3bad 100644 --- a/cmsis-pack-examples/kws/src/main_live.cpp +++ b/cmsis-pack-examples/kws/src/main_live.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -126,7 +126,7 @@ int main() const float secondsPerSample = 1.0 / arm::app::audio::MicroNetKwsMFCC::ms_defaultSamplingFreq; /* Classifier object for results */ - arm::app::Classifier classifier; + arm::app::KwsClassifier classifier; /* Object to hold label strings. */ std::vector labels; @@ -207,12 +207,8 @@ int main() while (audioDataSlider.HasNext()) { const int16_t* inferenceWindow = audioDataSlider.Next(); - /* The first window does not have cache ready. */ - preProcess.m_audioWindowIndex = audioDataSlider.Index(); - /* Run the pre-processing, inference and post-processing. */ - if (!preProcess.DoPreProcess( - inferenceWindow, arm::app::audio::MicroNetKwsMFCC::ms_defaultSamplingFreq)) { + if (!preProcess.DoPreProcess(inferenceWindow, audioDataSlider.Index())) { printf_err("Pre-processing failed."); return 1; } diff --git a/cmsis-pack-examples/kws/src/main_wav.cpp b/cmsis-pack-examples/kws/src/main_wav.cpp index ef03ea7..f12f72e 100644 --- a/cmsis-pack-examples/kws/src/main_wav.cpp +++ b/cmsis-pack-examples/kws/src/main_wav.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -102,7 +102,7 @@ int main() const float secondsPerSample = 1.0 / arm::app::audio::MicroNetKwsMFCC::ms_defaultSamplingFreq; /* Classifier object for results */ - arm::app::Classifier classifier; + arm::app::KwsClassifier classifier; /* Object to hold label strings. */ std::vector labels; @@ -135,15 +135,11 @@ int main() while (audioDataSlider.HasNext()) { const int16_t* inferenceWindow = audioDataSlider.Next(); - /* The first window does not have cache ready. */ - preProcess.m_audioWindowIndex = audioDataSlider.Index(); - info( "Inference %zu/%zu\n", audioDataSlider.Index() + 1, audioDataSlider.TotalStrides() + 1); /* Run the pre-processing, inference and post-processing. */ - if (!preProcess.DoPreProcess(inferenceWindow, - arm::app::audio::MicroNetKwsMFCC::ms_defaultSamplingFreq)) { + if (!preProcess.DoPreProcess(inferenceWindow, audioDataSlider.Index())) { printf_err("Pre-processing failed."); return 1; } diff --git a/cmsis-pack-examples/mlek.csolution.yml b/cmsis-pack-examples/mlek.csolution.yml index 6f0ca4c..94464a8 100644 --- a/cmsis-pack-examples/mlek.csolution.yml +++ b/cmsis-pack-examples/mlek.csolution.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -14,31 +14,31 @@ # See the License for the specific language governing permissions and # limitations under the License. -# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.0.0/tools/projmgr/schemas/csolution.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.4.0/tools/projmgr/schemas/csolution.schema.json solution: - created-for: cmsis-toolbox@2.0.0 + created-for: cmsis-toolbox@2.4.0 compiler: AC6 cdefault: # use default setup of toolchain specific controls. packs: - pack: ARM::CMSIS@5.9.0 - - pack: ARM::CMSIS-DSP@1.14.4 + - pack: ARM::CMSIS-DSP@1.15.0 - pack: ARM::CMSIS-NN@4.0.0 - - pack: Arm::ethos-u-core-driver@1.22.8 - - pack: ARM::ml-embedded-eval-kit-uc-api@22.8.0-Beta - - pack: tensorflow::flatbuffers@1.22.8 - - pack: tensorflow::gemmlowp@1.22.8 - - pack: tensorflow::kissfft@1.22.8 - - pack: tensorflow::ruy@1.22.8 - - pack: tensorflow::tensorflow-lite-micro@1.22.8 - - - pack: ARM::V2M_MPS3_SSE_300_BSP@1.3.0 - - pack: ARM::V2M_MPS3_SSE_310_BSP@1.0.0 + - pack: Arm::ethos-u-core-driver@1.23.2 + - pack: ARM::ml-embedded-eval-kit-uc-api@23.2.0 + - pack: tensorflow::flatbuffers@1.23.2 + - pack: tensorflow::gemmlowp@1.23.2 + - pack: tensorflow::kissfft@1.23.2 + - pack: tensorflow::ruy@1.23.2 + - pack: tensorflow::tensorflow-lite-micro@1.23.2 + + - pack: ARM::V2M_MPS3_SSE_300_BSP@1.4.0 + - pack: ARM::V2M_MPS3_SSE_310_BSP@1.3.0 - pack: NXP::FRDM-K64F_BSP@14.0.0 - pack: NXP::MK64F12_DFP@14.0.0 - pack: Keil::STM32F7xx_DFP@2.15.1 - - pack: AlifSemiconductor::Ensemble@0.5.2 + - pack: AlifSemiconductor::Ensemble@1.1.1 build-types: - type: Debug @@ -53,18 +53,22 @@ solution: target-types: - type: AVH-SSE-300 + board: ARM::V2M-MPS3-SSE-300-FVP device: ARM::SSE-300-MPS3 - type: AVH-SSE-300-U55 + board: ARM::V2M-MPS3-SSE-300-FVP device: ARM::SSE-300-MPS3 define: - ETHOSU55 - type: AVH-SSE-310 - device: ARM::SSE-310-MPS3 + board: ARM::V2M-MPS3-SSE-310 + device: ARM::SSE-310-MPS3_FVP - type: AVH-SSE-310-U55 - device: ARM::SSE-310-MPS3 + board: ARM::V2M-MPS3-SSE-310 + device: ARM::SSE-310-MPS3_FVP define: - ETHOSU55 @@ -77,13 +81,15 @@ solution: device: STM32F746NGHx - type: Alif-E7-M55-HP - device: AE722F80F55D5TE:M55_HP + board: Alif Semiconductor::DevKit-E7 + device: AE722F80F55D5LS:M55_HP define: - ETHOSU55 - USART_DRV_NUM: 2 - type: Alif-E7-M55-HE - device: AE722F80F55D5TE:M55_HE + board: Alif Semiconductor::DevKit-E7 + device: AE722F80F55D5LS:M55_HE define: - ETHOSU55 - USART_DRV_NUM: 4 @@ -91,12 +97,14 @@ solution: # NOTE: Currently Keil Studio Cloud doesn't allow switching between different NPU configurations. # Applications produced by this build will only work if the FVP is run manually. - type: AVH-SSE-300-U65 + board: ARM::V2M-MPS3-SSE-300-FVP device: ARM::SSE-300-MPS3 define: - ETHOSU65 - type: AVH-SSE-310-U65 - device: ARM::SSE-310-MPS3 + board: ARM::V2M-MPS3-SSE-310 + device: ARM::SSE-310-MPS3_FVP define: - ETHOSU65 diff --git a/cmsis-pack-examples/object-detection/linker/alif-e7-m55-hp.sct b/cmsis-pack-examples/object-detection/linker/alif-e7-m55-hp.sct index 4f642cf..1d6a65c 100644 --- a/cmsis-pack-examples/object-detection/linker/alif-e7-m55-hp.sct +++ b/cmsis-pack-examples/object-detection/linker/alif-e7-m55-hp.sct @@ -1,8 +1,8 @@ #! armclang -E --target=arm-arm-none-eabi -mcpu=cortex-m55 -xc ; command above MUST be in first line (no comment above!) -#include "../../device/alif-ensemble/RTE/Device/AE722F80F55D5TE_M55_HP/M55_HP_map.h" +#include "../../device/alif-ensemble/RTE/Device/AE722F80F55D5LS_M55_HP/M55_HP_map.h" -; SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its +; SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its ; affiliates ; SPDX-License-Identifier: Apache-2.0 ; @@ -34,7 +34,7 @@ #define RGB_BUFFER_SIZE (0x00132400) /* ~1.2 MiB of RGB and RAW buffers */ #define ARENA_SIZE (0x00196400) /* ~1.6 MiB of arena */ -#define MODEL_BASE (SRAM0_BASE) +#define MODEL_BASE (SRAM0_BASE + 0x100000) #define DTCM_DATA_SIZE (SRAM3_SIZE - __HEAP_SIZE - __STACK_SIZE) @@ -67,12 +67,12 @@ LOAD_REGION_0 ROM_BASE SRAM2_SIZE {} } -LOAD_REGION_1 (HEAP_BASE+__HEAP_SIZE) ALIGN 4 DTCM_DATA_SIZE +LOAD_REGION_1 (HEAP_BASE+__HEAP_SIZE) ALIGN 8 DTCM_DATA_SIZE { ;----------------------------------------------------- ; Remaining DTCM for R/O and R/W data ;----------------------------------------------------- - hp_dtcm (HEAP_BASE+__HEAP_SIZE) ALIGN 4 DTCM_DATA_SIZE + hp_dtcm (HEAP_BASE+__HEAP_SIZE) ALIGN 8 DTCM_DATA_SIZE { .ANY (+RW +ZI) .ANY (+RO-DATA) @@ -82,7 +82,7 @@ LOAD_REGION_1 (HEAP_BASE+__HEAP_SIZE) ALIGN 4 DTCM_DATA_SIZE ;--------------------------------------------------------- ; Second load region (SRAM0) ;--------------------------------------------------------- -LOAD_REGION_2 SRAM0_BASE SRAM0_SIZE +LOAD_REGION_2 MODEL_BASE SRAM0_SIZE { ;----------------------------------------------------- ; SRAM0 space for nn model and input vectors diff --git a/cmsis-pack-examples/object-detection/object-detection.cproject.yml b/cmsis-pack-examples/object-detection/object-detection.cproject.yml index df61704..7b4830b 100644 --- a/cmsis-pack-examples/object-detection/object-detection.cproject.yml +++ b/cmsis-pack-examples/object-detection/object-detection.cproject.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.0.0/tools/projmgr/schemas/cproject.schema.json +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/schemas/projmgr/2.4.0/tools/projmgr/schemas/cproject.schema.json project: output: diff --git a/cmsis-pack-examples/object-detection/src/main_live.cpp b/cmsis-pack-examples/object-detection/src/main_live.cpp index a2cb562..acbedd3 100644 --- a/cmsis-pack-examples/object-detection/src/main_live.cpp +++ b/cmsis-pack-examples/object-detection/src/main_live.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2021-2024 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -40,7 +40,6 @@ #include "BoardInit.hpp" /* Board initialisation */ #include "log_macros.h" /* Logging macros (optional) */ - #define CROPPED_IMAGE_WIDTH 192 #define CROPPED_IMAGE_HEIGHT 192 #define CROPPED_IMAGE_SIZE (CROPPED_IMAGE_WIDTH * CROPPED_IMAGE_HEIGHT * 3) @@ -57,7 +56,7 @@ namespace app { static uint8_t rawImage[CAMERA_IMAGE_RAW_SIZE] __attribute__((section("raw_buf"), aligned(16))); /* LCD image buffer */ - static uint8_t lcdImage[DIMAGE_Y][DIMAGE_X][RGB_BYTES] __attribute__((section("lcd_buf"), aligned(16))); + static uint8_t lcdImage[DIMAGE_Y][DIMAGE_X][LCD_BYTES_PER_PIXEL] __attribute__((section("lcd_buf"), aligned(16))); /* Optional getter function for the model pointer and its size. */ namespace object_detection { @@ -137,7 +136,7 @@ int main() const size_t imgSz = inputTensor->bytes < CROPPED_IMAGE_SIZE ? inputTensor->bytes : CROPPED_IMAGE_SIZE; - if (0 != arm::app::CameraCaptureInit(CAMERA_RESOLUTION)) { + if (0 != arm::app::CameraCaptureInit()) { printf_err("Failed to initalise camera\n"); return 2; } @@ -151,13 +150,15 @@ int main() arm::app::LcdDisplayInit(&arm::app::lcdImage[0][0][0], DIMAGE_X, DIMAGE_Y); /* LCD initialisation */ - arm::app::GpioSignal statusLED {arm::app::SignalPort::Port1, - arm::app::SignalPin::Port1_StatusLED2, - arm::app::SignalDirection::DirectionOutput}; + arm::app::GpioSignal statusLED {arm::app::SignalPort::Port12, + arm::app::SignalPin::Port12_LED0_R, + arm::app::SignalDirection::DirectionOutput}; /* Start the camera */ - arm::app::CameraCaptureStart(arm::app::rawImage); - arm::app::CameraCaptureWaitForFrame(); + if (0 != arm::app::CameraCaptureStart(arm::app::rawImage)) { + printf_err("Failed to start camera capture\n"); + return 4; + } auto dstPtr = static_cast(inputTensor->data.uint8); @@ -177,14 +178,17 @@ int main() arm::app::rgbImage, inputImgCols, inputImgRows, - arm::app::ColourFilter::BGGR); + arm::app::ColourFilter::GRBG); + if (!debayerState) { printf_err("Debayering failed\n"); return 1; } - arm::app::CameraCaptureStart(arm::app::rawImage); + if (0 != arm::app::CameraCaptureStart(arm::app::rawImage)) { + printf_err("Failed to start camera capture\n"); + } /* Run the pre-processing, inference and post-processing. */ if (!preProcess.DoPreProcess(arm::app::rgbImage, imgSz)) { @@ -193,7 +197,9 @@ int main() } /* Run inference over this image. */ - printf("\rImage %" PRIu32 "; ", ++imgCount); + if (!(imgCount++ & 0xF)) { + printf("\rImage %" PRIu32 "; ", imgCount); + } statusLED.Send(true); if (!model.RunInference()) { @@ -210,14 +216,12 @@ int main() DrawDetectionBoxes(arm::app::rgbImage, inputImgCols, inputImgRows, results); - arm::app::RotateClockwise90(arm::app::rgbImage, inputImgCols, inputImgRows); - arm::app::LcdDisplayImage(arm::app::rgbImage, - inputImgCols, - inputImgRows, - arm::app::ColourFormat::RGB, - (DIMAGE_X - inputImgCols)/2, - (DIMAGE_Y - inputImgRows)/2); + inputImgCols, + inputImgRows, + arm::app::ColourFormat::RGB, + (DIMAGE_X - inputImgCols)/2, + (DIMAGE_Y - inputImgRows)/2); } return 0; diff --git a/cmsis-pack-examples/vcpkg-configuration.json b/cmsis-pack-examples/vcpkg-configuration.json index 25691c5..264a1e4 100644 --- a/cmsis-pack-examples/vcpkg-configuration.json +++ b/cmsis-pack-examples/vcpkg-configuration.json @@ -19,7 +19,7 @@ "requires": { "microsoft:tools/kitware/cmake": "^3.25.2", "microsoft:tools/ninja-build/ninja": "^1.10.2", - "arm:tools/open-cmsis-pack/cmsis-toolbox": "^2.0.0", - "arm:compilers/arm/armclang": "^6.18.0" + "arm:tools/open-cmsis-pack/cmsis-toolbox": "^2.4.0", + "arm:compilers/arm/armclang": "^6.22.0" } }