diff options
author | Kshitij Sisodia <kshitij.sisodia@arm.com> | 2022-03-14 09:26:48 +0000 |
---|---|---|
committer | Kshitij Sisodia <kshitij.sisodia@arm.com> | 2022-03-14 17:18:25 +0000 |
commit | c22e80e25521bdd291fdef9ba20194ce9d2a8544 (patch) | |
tree | b8ffe314220d4d04e84dbd6a240f77271c1e5e70 /source/hal | |
parent | 1716efd0b35889b580276e27c8b6f661c9858cd0 (diff) | |
download | ml-embedded-evaluation-kit-c22e80e25521bdd291fdef9ba20194ce9d2a8544.tar.gz |
MLECO-2919: Restructuring to standardise HAL APIs
* LCD module component created (removed from individual
platform packs).
* retarget.c moved out into its own component that wraps
the uart module. It also have the native stub for
GetLine => paved the way for removing data_acq module
from profiles.
* shortened names for components' dir for npu and ta
* remove peripheral_memmap and peripheral_irqs headers
from platform_drivers.h. There should be no need for
these to be included in the top level now. These should
be private headers.
* cmsis_device moved in as a component.
* Pyenv created by set_up_default_resource.py will also
install packages that CMake's source generator needs.
TODO's:
* Remove timer from profiles (MLECO-3096)
Change-Id: I9d6ea2f4f291788f40a16ed507019563c8d7f205
Diffstat (limited to 'source/hal')
-rw-r--r-- | source/hal/CMakeLists.txt | 66 | ||||
-rw-r--r-- | source/hal/platform/mps3/source/device_mps3.c | 41 | ||||
-rw-r--r-- | source/hal/platform/simple/include/stubs/glcd.h | 112 | ||||
-rw-r--r-- | source/hal/profiles/native/data_acquisition/data_acq.c | 63 | ||||
-rw-r--r-- | source/hal/profiles/native/data_presentation/data_psn.c | 45 | ||||
-rw-r--r-- | source/hal/profiles/native/data_presentation/log/include/log.h | 87 | ||||
-rw-r--r-- | source/hal/profiles/native/data_presentation/log/log.c | 84 | ||||
-rw-r--r-- | source/hal/source/components/cmsis_device/CMakeLists.txt (renamed from source/hal/cmsis_device/CMakeLists.txt) | 22 | ||||
-rw-r--r-- | source/hal/source/components/cmsis_device/include/RTE_Components.h (renamed from source/hal/cmsis_device/include/RTE_Components.h) | 0 | ||||
-rw-r--r-- | source/hal/source/components/cmsis_device/source/handlers.c (renamed from source/hal/cmsis_device/source/handlers.c) | 0 | ||||
-rw-r--r-- | source/hal/source/components/lcd/CMakeLists.txt | 90 | ||||
-rw-r--r-- | source/hal/source/components/lcd/include/lcd_img.h (renamed from source/hal/profiles/bare-metal/data_presentation/lcd/include/lcd_img.h) | 0 | ||||
-rw-r--r-- | source/hal/source/components/lcd/source/glcd.h (renamed from source/hal/platform/mps3/include/glcd_mps3.h) | 6 | ||||
-rw-r--r-- | source/hal/source/components/lcd/source/glcd_mps3/font_9x15_h.h (renamed from source/hal/platform/mps3/source/font_9x15_h.h) | 0 | ||||
-rw-r--r-- | source/hal/source/components/lcd/source/glcd_mps3/glcd_mps3.c (renamed from source/hal/platform/mps3/source/glcd_mps3.c) | 18 | ||||
-rw-r--r-- | source/hal/source/components/lcd/source/glcd_stubs/glcd_stubs.c (renamed from source/hal/platform/simple/source/stubs_glcd.c) | 2 | ||||
-rw-r--r-- | source/hal/source/components/lcd/source/lcd_img.c (renamed from source/hal/profiles/bare-metal/data_presentation/lcd/lcd_img.c) | 2 | ||||
-rw-r--r-- | source/hal/source/components/npu/CMakeLists.txt (renamed from source/hal/components/ethosu_npu_init/CMakeLists.txt) | 8 | ||||
-rw-r--r-- | source/hal/source/components/npu/ethosu_cpu_cache.c | 54 | ||||
-rw-r--r-- | source/hal/source/components/npu/ethosu_npu_init.c (renamed from source/hal/components/ethosu_npu_init/ethosu_npu_init.c) | 8 | ||||
-rw-r--r-- | source/hal/source/components/npu/include/ethosu_cpu_cache.h | 39 | ||||
-rw-r--r-- | source/hal/source/components/npu/include/ethosu_mem_config.h (renamed from source/hal/components/ethosu_npu_init/include/ethosu_mem_config.h) | 0 | ||||
-rw-r--r-- | source/hal/source/components/npu/include/ethosu_npu_init.h (renamed from source/hal/components/ethosu_npu_init/include/ethosu_npu_init.h) | 0 | ||||
-rw-r--r-- | source/hal/source/components/npu_ta/CMakeLists.txt (renamed from source/hal/components/ethosu_ta_init/CMakeLists.txt) | 12 | ||||
-rw-r--r-- | source/hal/source/components/npu_ta/cmake/templates/timing_adapter_settings.template (renamed from source/hal/components/ethosu_ta_init/cmake/templates/timing_adapter_settings.template) | 0 | ||||
-rw-r--r-- | source/hal/source/components/npu_ta/ethosu_ta_init.c (renamed from source/hal/components/ethosu_ta_init/ethosu_ta_init.c) | 0 | ||||
-rw-r--r-- | source/hal/source/components/npu_ta/include/ethosu_ta_init.h (renamed from source/hal/components/ethosu_ta_init/include/ethosu_ta_init.h) | 0 | ||||
-rw-r--r-- | source/hal/source/components/stdout/CMakeLists.txt | 110 | ||||
-rw-r--r-- | source/hal/source/components/stdout/include/user_input.h | 30 | ||||
-rw-r--r-- | source/hal/source/components/stdout/source/retarget.c (renamed from source/hal/profiles/bare-metal/bsp/retarget.c) | 0 | ||||
-rw-r--r-- | source/hal/source/components/stdout/source/user_input.c | 33 | ||||
-rw-r--r-- | source/hal/source/data_acq.c (renamed from source/hal/profiles/bare-metal/data_acquisition/data_acq.c) | 1 | ||||
-rw-r--r-- | source/hal/source/data_psn.c (renamed from source/hal/profiles/bare-metal/data_presentation/data_psn.c) | 0 | ||||
-rw-r--r-- | source/hal/source/hal.c (renamed from source/hal/hal.c) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/CMakeLists.txt (renamed from source/hal/platform/mps3/CMakeLists.txt) | 53 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/cmake/subsystem-profiles/sse-300.cmake (renamed from source/hal/platform/mps3/cmake/subsystem-profiles/sse-300.cmake) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/cmake/templates/mem_regions.h.template (renamed from source/hal/platform/mps3/cmake/templates/mem_regions.h.template) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/cmake/templates/peripheral_irqs.h.template (renamed from source/hal/platform/mps3/cmake/templates/peripheral_irqs.h.template) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/cmake/templates/peripheral_memmap.h.template (renamed from source/hal/platform/mps3/cmake/templates/peripheral_memmap.h.template) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/cmake/templates/timing_adapter_settings.template (renamed from source/hal/platform/mps3/cmake/templates/timing_adapter_settings.template) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/include/platform_drivers.h (renamed from source/hal/platform/mps3/include/platform_drivers.h) | 9 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/include/timer_mps3.h (renamed from source/hal/platform/mps3/include/timer_mps3.h) | 9 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/source/device_mps3.h (renamed from source/hal/platform/mps3/source/device_mps3.h) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/source/platform_drivers.c (renamed from source/hal/platform/mps3/source/platform_drivers.c) | 14 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/source/smm_mps3.h (renamed from source/hal/platform/mps3/source/smm_mps3.h) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/mps3/source/timer_mps3.c (renamed from source/hal/platform/mps3/source/timer_mps3.c) | 25 | ||||
-rw-r--r-- | source/hal/source/platform/native/CMakeLists.txt (renamed from source/hal/platform/native/CMakeLists.txt) | 24 | ||||
-rw-r--r-- | source/hal/source/platform/native/include/platform_drivers.h (renamed from source/hal/platform/native/include/platform_drivers.h) | 2 | ||||
-rw-r--r-- | source/hal/source/platform/native/source/platform_drivers.c (renamed from source/hal/platform/native/source/platform_drivers.c) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/simple/CMakeLists.txt (renamed from source/hal/platform/simple/CMakeLists.txt) | 37 | ||||
-rw-r--r-- | source/hal/source/platform/simple/cmake/subsystem-profiles/simple_platform.cmake (renamed from source/hal/platform/simple/cmake/subsystem-profiles/simple_platform.cmake) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/simple/cmake/templates/mem_regions.h.template (renamed from source/hal/platform/simple/cmake/templates/mem_regions.h.template) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/simple/cmake/templates/peripheral_irqs.h.template (renamed from source/hal/platform/simple/cmake/templates/peripheral_irqs.h.template) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/simple/cmake/templates/peripheral_memmap.h.template (renamed from source/hal/platform/simple/cmake/templates/peripheral_memmap.h.template) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/simple/cmake/templates/timing_adapter_settings.template (renamed from source/hal/platform/simple/cmake/templates/timing_adapter_settings.template) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/simple/include/platform_drivers.h (renamed from source/hal/platform/simple/include/platform_drivers.h) | 9 | ||||
-rw-r--r-- | source/hal/source/platform/simple/include/timer_simple_platform.h (renamed from source/hal/platform/simple/include/timer_simple_platform.h) | 0 | ||||
-rw-r--r-- | source/hal/source/platform/simple/source/platform_drivers.c (renamed from source/hal/platform/simple/source/platform_drivers.c) | 3 | ||||
-rw-r--r-- | source/hal/source/platform/simple/source/timer_simple_platform.c (renamed from source/hal/platform/simple/source/timer_simple_platform.c) | 0 | ||||
-rw-r--r-- | source/hal/source/profiles/bare-metal/timer/include/platform_timer.h (renamed from source/hal/profiles/bare-metal/timer/include/platform_timer.h) | 0 | ||||
-rw-r--r-- | source/hal/source/profiles/bare-metal/timer/platform_timer.c (renamed from source/hal/profiles/bare-metal/timer/platform_timer.c) | 0 | ||||
-rw-r--r-- | source/hal/source/profiles/native/timer/include/platform_timer.h (renamed from source/hal/profiles/native/timer/include/platform_timer.h) | 0 | ||||
-rw-r--r-- | source/hal/source/profiles/native/timer/platform_timer.c (renamed from source/hal/profiles/native/timer/platform_timer.c) | 0 |
63 files changed, 541 insertions, 577 deletions
diff --git a/source/hal/CMakeLists.txt b/source/hal/CMakeLists.txt index f720cdf..19f152c 100644 --- a/source/hal/CMakeLists.txt +++ b/source/hal/CMakeLists.txt @@ -37,7 +37,7 @@ else() set(PLATFORM_PROFILE native) endif() -set(PLATFORM_PROFILE_DIR profiles/${PLATFORM_PROFILE}) +set(PLATFORM_PROFILE_DIR source/profiles/${PLATFORM_PROFILE}) ## Common include directories - public target_include_directories(${HAL_TARGET} @@ -48,9 +48,9 @@ target_include_directories(${HAL_TARGET} ## Common sources for all profiles target_sources(${HAL_TARGET} PRIVATE - hal.c - ${PLATFORM_PROFILE_DIR}/data_presentation/data_psn.c - ${PLATFORM_PROFILE_DIR}/data_acquisition/data_acq.c + source/hal.c + source/data_psn.c + source/data_acq.c ${PLATFORM_PROFILE_DIR}/timer/platform_timer.c) if (DEFINED VERIFY_TEST_OUTPUT) @@ -60,56 +60,7 @@ if (DEFINED VERIFY_TEST_OUTPUT) endif () if (NOT DEFINED PLATFORM_DRIVERS_DIR) - message(FATAL_ERROR "PLATFORM_DRIVERS_DIR need to be defined for this target") -endif() - - -############################ bare-metal profile ############################# -if (PLATFORM_PROFILE STREQUAL bare-metal) - - ## Additional include directories - private - target_include_directories(${HAL_TARGET} - PRIVATE - ${PLATFORM_PROFILE_DIR}/data_presentation/lcd/include) - - ## Additional sources - public - target_sources(${HAL_TARGET} - PUBLIC - ${PLATFORM_PROFILE_DIR}/bsp/retarget.c) - - ## Additional sources - private - target_sources(${HAL_TARGET} - PRIVATE - ${PLATFORM_PROFILE_DIR}/data_presentation/lcd/lcd_img.c) - - ## Compile definition: - target_compile_definitions(${HAL_TARGET} - PUBLIC - PLATFORM_HAL=PLATFORM_CORTEX_M_BAREMETAL) - - # Add dependencies for platform_driver first, in case they are needed by it. - add_subdirectory(cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device) - -############################ native profile ############################# -elseif (PLATFORM_PROFILE STREQUAL native) - - ## Additional include directories - private - target_include_directories(${HAL_TARGET} - PRIVATE - ${PLATFORM_PROFILE_DIR}/data_presentation/log/include) - - ## Additional sources - private - target_sources(${HAL_TARGET} - PRIVATE - ${PLATFORM_PROFILE_DIR}/data_presentation/log/log.c) - - ## Compile definition: - target_compile_definitions(${HAL_TARGET} - PUBLIC - PLATFORM_HAL=PLATFORM_UNKNOWN_LINUX_OS - ACTIVATION_BUF_SRAM_SZ=0) -else() - message(FATAL_ERROR "PLATFORM_PROFILE ${PLATFORM_PROFILE} not supported") + message(FATAL_ERROR "PLATFORM_DRIVERS_DIR undefined") endif() # Add platform_drivers target @@ -118,8 +69,11 @@ add_subdirectory(${PLATFORM_DRIVERS_DIR} ${CMAKE_BINARY_DIR}/platform_driver) # Link time library targets: target_link_libraries(${HAL_TARGET} PUBLIC - log - platform_drivers) + log # Logging functions + lcd_iface # LCD interface + stdout_iface # Standard output (and error) interface + platform_drivers # Platform drivers implementing the required interfaces +) # Display status: message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/source/hal/platform/mps3/source/device_mps3.c b/source/hal/platform/mps3/source/device_mps3.c deleted file mode 100644 index de715fb..0000000 --- a/source/hal/platform/mps3/source/device_mps3.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021-2022 Arm Limited. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "device_mps3.h" - -#include "log_macros.h" -#include "smm_mps3.h" - -#include <inttypes.h> - -uint32_t GetMPS3CoreClock(void) -{ - const uint32_t default_clock = 32000000 /* 32 MHz clock */; - static int warned_once = 0; - if (0 != MPS3_SCC->CFG_ACLK) { - if (default_clock != MPS3_SCC->CFG_ACLK) { - warn("System clock is different to the MPS3 config set clock.\n"); - } - return MPS3_SCC->CFG_ACLK; - } - - if (!warned_once) { - warn("MPS3_SCC->CFG_ACLK reads 0. Assuming default clock of %" PRIu32 "\n", - default_clock); - warned_once = 1; - } - return default_clock; -} diff --git a/source/hal/platform/simple/include/stubs/glcd.h b/source/hal/platform/simple/include/stubs/glcd.h deleted file mode 100644 index b31938f..0000000 --- a/source/hal/platform/simple/include/stubs/glcd.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2021-2022 Arm Limited. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef STUBS_SIMPLE_PLATFORM_H -#define STUBS_SIMPLE_PLATFORM_H - -#include <stdint.h> - -/****************************************************************************/ -/* Definitions and stub functions for modules currently */ -/* unavailable on this target platform */ -/****************************************************************************/ -#define GLCD_WIDTH 320 -#define GLCD_HEIGHT 240 -#define Black 0x0000 /* 0, 0, 0 */ -#define White 0xFFFF /* 255, 255, 255 */ - -/************************ GLCD related functions ****************************/ -/** - * @brief Initialize the Himax LCD with HX8347-D LCD Controller - */ -void GLCD_Initialize(void); - -/** - * @brief Display graphical bitmap image at position x horizontally and y - * vertically. This function is optimized for 16 bits per pixel - * format, it has to be adapted for any other format. - * @param[in] x horizontal position. - * @param[in] y vertical position. - * @param[in] w width of bitmap. - * @param[in] h height of bitmap. - * @param[in] bitmap address at which the bitmap data resides. - */ -void GLCD_Bitmap(unsigned int x, unsigned int y, - unsigned int w, unsigned int h, - unsigned short *bitmap); - -/** - * @brief Displays an 8 bit image, conversion to the LCD's - * 16 bit codec is done on the fly. - * @param[in] data pointer to the full sized image data. - * @param[in] width image width. - * @param[in] height image height. - * @param[in] channels number of channels in the image. - * @param[in] pos_x start x position for the LCD. - * @param[in] pos_y start y position for the LCD. - * @param[in] downsample_factor factor by which the image - * is downsampled by. - */ -void GLCD_Image(const void *data, const uint32_t width, - const uint32_t height, const uint32_t channels, - const uint32_t pos_x, const uint32_t pos_y, - const uint32_t downsample_factor); - -/** - * @brief Clear display - * @param[in] color display clearing color - */ -void GLCD_Clear(unsigned short color); - -/** - * @brief Set foreground color - * @param[in] color foreground color - */ -void GLCD_SetTextColor(unsigned short color); - -/** - * @brief Display character on given line - * @param[in] ln line number - * @param[in] col column number - * @param[in] fi font index (0 = 9x15) - * @param[in] c ASCII character - */ -void GLCD_DisplayChar(unsigned int ln, unsigned int col, - unsigned char fi, unsigned char c); - -/** - * @brief Display string on given line - * @param[in] ln line number - * @param[in] col column number - * @param[in] fi font index (0 = 9x15) - * @param[in] s pointer to string - */ -void GLCD_DisplayString(unsigned int ln, unsigned int col, - unsigned char fi, char *s); - -/** - * @brief Draw box filled with color - * @param[in] x horizontal position - * @param[in] y: vertical position - * @param[in] w: window width in pixels - * @param[in] h: window height in pixels - * @param[in] color box color - */ -void GLCD_Box(unsigned int x, unsigned int y, - unsigned int w, unsigned int h, - unsigned short color); - -#endif /* STUBS_SIMPLE_PLATFORM_H */ diff --git a/source/hal/profiles/native/data_acquisition/data_acq.c b/source/hal/profiles/native/data_acquisition/data_acq.c deleted file mode 100644 index 9b6815b..0000000 --- a/source/hal/profiles/native/data_acquisition/data_acq.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Arm Limited. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "data_acq.h" - -#include <assert.h> -#include <stdio.h> -#include <string.h> - -/** - * @brief Initialize the acuisition. - * @return 0 if successful, error code otherwise. - **/ -static int acquisition_init(void) -{ - return 0; -} - -/** - * @brief Get the user input from stdin. - * @param[out] user_input String read from the stdin. - * @param[in,out] size String read length. - * @return 0 if successful, error code otherwise. - **/ -static int get_user_input(char* user_input, int size) -{ - if (NULL == fgets(user_input, size, stdin)) { - return 1; - } - return 0; -} - -int data_acq_channel_init(data_acq_module *module) -{ - assert(module); - - module->system_init = acquisition_init; - module->get_input = get_user_input; - strncpy(module->system_name, "native", - sizeof(module->system_name)); - module->inited = !module->system_init(); - return !module->inited; -} - -int data_acq_channel_release(data_acq_module *module) -{ - assert(module); - module->inited = 0; - return 0; -} diff --git a/source/hal/profiles/native/data_presentation/data_psn.c b/source/hal/profiles/native/data_presentation/data_psn.c deleted file mode 100644 index fe4bcfa..0000000 --- a/source/hal/profiles/native/data_presentation/data_psn.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2021 Arm Limited. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "data_psn.h" - -#include "log.h" - -#include <assert.h> -#include <string.h> - -int data_psn_system_init(data_psn_module *module) -{ - assert(module); - - module->system_init = log_psn_init; - module->present_data_image = log_display_image; - module->present_data_text = log_display_text; - module->present_box = log_display_box_icon; - module->set_text_color = log_set_text_color; - module->clear = log_clear; - strncpy(module->system_name, "log_psn", sizeof(module->system_name)); - module->inited = !module->system_init(); - return !module->inited; -} - -int data_psn_system_release(data_psn_module *module) -{ - /* Nothing to do here! */ - assert(module); - module->inited = 0; - return 0; -} diff --git a/source/hal/profiles/native/data_presentation/log/include/log.h b/source/hal/profiles/native/data_presentation/log/include/log.h deleted file mode 100644 index 796d0ef..0000000 --- a/source/hal/profiles/native/data_presentation/log/include/log.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2021-2022 Arm Limited. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef NATIVE_LOG_H -#define NATIVE_LOG_H - -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> - -/** - * @brief Data presentation initialiser - **/ -int log_psn_init(void); - -/** - * @brief Log parameters for the image to be displayed. - * @param[in] data Image pointer. - * @param[in] width Image width. - * @param[in] height Image height. - * @param[in] channels Number of channels. - * @param[in] pos_x Screen position x co-ordinate. - * @param[in] pos_y Screen position y co-ordinate. - * @param[in] downsample_factor Factor by which the image needs to be - * down-sampled. - * @return 0 if successful, non-zero otherwise. - **/ - -int log_display_image(const uint8_t* data, const uint32_t width, - const uint32_t height, const uint32_t channels, - const uint32_t pos_x, const uint32_t pos_y, - const uint32_t downsample_factor); - -/** - * @brief Log the parameters for text to be displayed. - * @param[in] str Pointer to a null terminated string. - * @param[in] str_sz Length of the string. - * @param[in] pos_x Screen position x co-ordinate. - * @param[in] pos_y Screen position y co-ordinate. - * @param[in] allow_multiple_lines Specifies if multiple lines are allowed. - * @return 0 if successful, non-zero otherwise. - **/ -int log_display_text(const char* str, const size_t str_sz, - const uint32_t pos_x, const uint32_t pos_y, - const bool allow_multiple_lines); - -/** - * @brief Log parameters for the box to be displayed. - * @param[in] pos_x Screen position x co-ordinate. - * @param[in] pos_y Screen position y co-ordinate. - * @param[in] width Width. - * @param[in] height Height. - * @param[in] color Fill color. - * @return 0 if successful, non-zero otherwise. - **/ -int log_display_box_icon(const uint32_t pos_x, const uint32_t pos_y, - const uint32_t width, const uint32_t height, const uint16_t color); - -/** - * @brief Logs the colour with which the display - * needs to be cleared with. - * @param[in] color Fill color. - * @return 0 if successful, non-zero otherwise. - **/ -int log_clear(const uint16_t color); - -/** - * @brief Logs the text color to be set. - * @param[in] color Fill color. - * @return 0 if successful, non-zero otherwise. - **/ -int log_set_text_color (const uint16_t color); - -#endif /* NATIVE_LOG_H */
\ No newline at end of file diff --git a/source/hal/profiles/native/data_presentation/log/log.c b/source/hal/profiles/native/data_presentation/log/log.c deleted file mode 100644 index e37b4ca..0000000 --- a/source/hal/profiles/native/data_presentation/log/log.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2021-2022 Arm Limited. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "log.h" -#include "log_macros.h" - -#include <stdint.h> - -#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wunused-parameter" -#elif defined(__GNUC__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -int log_psn_init(void) -{ - return 0; -} - -int log_display_image(const uint8_t* data, const uint32_t width, - const uint32_t height, const uint32_t channels, - const uint32_t pos_x, const uint32_t pos_y, - const uint32_t downsample_factor) -{ - debug("Image details\n"); - debug("Data: %p\n", data); - debug("WxHxC: %dx%dx%d\n", width, height, channels); - debug("Pos (x,y): (%d,%d)\n", pos_x, pos_y); - debug("Downsampling factor: %u\n", downsample_factor); - return 0; -} - -int log_display_text(const char* str, const size_t str_sz, - const uint32_t pos_x, const uint32_t pos_y, - const bool allow_multiple_lines) -{ - UNUSED(allow_multiple_lines); - debug("%s\n", str); - debug("Text size: %lu, x: %d, y: %d\n", str_sz, pos_x, pos_y); - return 0; -} - - -int log_display_box_icon(const uint32_t pos_x, const uint32_t pos_y, - const uint32_t width, const uint32_t height, - const uint16_t color) -{ - debug("Showing rectangular, width: %d, height: %d, color: %d, x: %d, y: %d\n", - width, height, color, pos_x, pos_y); - return 0; -} - -int log_clear(const uint16_t color) -{ - debug("Clearing with color: %d\n", color); - return 0; -} - -int log_set_text_color (const uint16_t color) -{ - debug("Setting text color: %d\n", color); - return 0; -} - -#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #pragma clang diagnostic pop -#elif defined(__GNUC__) - #pragma GCC diagnostic pop -#endif diff --git a/source/hal/cmsis_device/CMakeLists.txt b/source/hal/source/components/cmsis_device/CMakeLists.txt index 05c6005..dcaeff5 100644 --- a/source/hal/cmsis_device/CMakeLists.txt +++ b/source/hal/source/components/cmsis_device/CMakeLists.txt @@ -21,6 +21,7 @@ cmake_minimum_required(VERSION 3.15.6) set(CMSIS_DEVICE_TARGET cmsis_device) +set(CPU_HEADER_TARGET cmsis_device_cpu_header) project(${CMSIS_DEVICE_TARGET} DESCRIPTION "Generic CMSIS start up file for Cortex-M targets" @@ -36,22 +37,26 @@ if (NOT DEFINED CMSIS_SRC_PATH) message(FATAL_ERROR "CMSIS_SRC_PATH path should be defined for ${CMSIS_DEVICE_TARGET}.") endif() -# 3. Create static library -add_library(${CMSIS_DEVICE_TARGET} STATIC) +# 3.1 Create an interface library for CPU header only +add_library(${CPU_HEADER_TARGET} INTERFACE) -## Include directories - public -target_include_directories(${CMSIS_DEVICE_TARGET} - PUBLIC +## Interface include directories: +target_include_directories(${CPU_HEADER_TARGET} + INTERFACE include ${CMSIS_SRC_PATH}/CMSIS/Core/Include ${CMSIS_SRC_PATH}/Device/ARM/${ARM_CPU}/Include ${CMSIS_SRC_PATH}/Device/ARM/${ARM_CPU}/Include/Template) -## Sources +# 3.2 Create static library +add_library(${CMSIS_DEVICE_TARGET} STATIC) + +## Sources - public target_sources(${CMSIS_DEVICE_TARGET} PUBLIC source/handlers.c) +## Sources - private target_sources(${CMSIS_DEVICE_TARGET} PRIVATE ${CMSIS_SRC_PATH}/Device/ARM/${ARM_CPU}/Source/system_${ARM_CPU}.c @@ -66,6 +71,11 @@ target_link_options( INTERFACE --entry Reset_Handler) +# Link libraries +target_link_libraries(${CMSIS_DEVICE_TARGET} + PUBLIC + ${CPU_HEADER_TARGET}) + # Check if semihosting configuration is available if (COMMAND configure_semihosting) configure_semihosting(${CMSIS_DEVICE_TARGET} OFF) diff --git a/source/hal/cmsis_device/include/RTE_Components.h b/source/hal/source/components/cmsis_device/include/RTE_Components.h index 8988e9b..8988e9b 100644 --- a/source/hal/cmsis_device/include/RTE_Components.h +++ b/source/hal/source/components/cmsis_device/include/RTE_Components.h diff --git a/source/hal/cmsis_device/source/handlers.c b/source/hal/source/components/cmsis_device/source/handlers.c index a3119e6..a3119e6 100644 --- a/source/hal/cmsis_device/source/handlers.c +++ b/source/hal/source/components/cmsis_device/source/handlers.c diff --git a/source/hal/source/components/lcd/CMakeLists.txt b/source/hal/source/components/lcd/CMakeLists.txt new file mode 100644 index 0000000..7378713 --- /dev/null +++ b/source/hal/source/components/lcd/CMakeLists.txt @@ -0,0 +1,90 @@ +#---------------------------------------------------------------------------- +# Copyright (c) 2022 Arm Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#---------------------------------------------------------------------------- + +######################################################### +# LCD library # +######################################################### + +cmake_minimum_required(VERSION 3.15.6) + +project(lcd_component + DESCRIPTION "LCD support library" + LANGUAGES C CXX ASM) + +# Add top level interface library +set(LCD_IFACE_TARGET lcd_iface) +add_library(${LCD_IFACE_TARGET} INTERFACE) +target_include_directories(${LCD_IFACE_TARGET} INTERFACE include) + +# Create static library for MPS3 LCD +set(LCD_MPS3_COMPONENT_TARGET lcd_mps3) +add_library(${LCD_MPS3_COMPONENT_TARGET} STATIC) + +set(CLCD_CONFIG_BASE "0x4930A000" CACHE STRING "LCD configuration base address") + +## Include directories - private +target_include_directories(${LCD_MPS3_COMPONENT_TARGET} + PRIVATE + source) + +## Component sources +target_sources(${LCD_MPS3_COMPONENT_TARGET} + PRIVATE + source/glcd_mps3/glcd_mps3.c + source/lcd_img.c) + +# Compile definitions +target_compile_definitions(${LCD_MPS3_COMPONENT_TARGET} + PRIVATE + CLCD_CONFIG_BASE=${CLCD_CONFIG_BASE}) + +## Add dependencies +target_link_libraries(${LCD_MPS3_COMPONENT_TARGET} PUBLIC + ${LCD_IFACE_TARGET} + log) + +# Display status +message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) +message(STATUS "*******************************************************") +message(STATUS "Library : " ${LCD_MPS3_COMPONENT_TARGET}) +message(STATUS "*******************************************************") + +# Create static library for LCD Stubs +set(LCD_STUBS_COMPONENT_TARGET lcd_stubs) +add_library(${LCD_STUBS_COMPONENT_TARGET} STATIC) + +## Include directories - private +target_include_directories(${LCD_STUBS_COMPONENT_TARGET} + PRIVATE + source) + +## Component sources +target_sources(${LCD_STUBS_COMPONENT_TARGET} + PRIVATE + source/glcd_stubs/glcd_stubs.c + source/lcd_img.c) + +## Add dependencies +target_link_libraries(${LCD_STUBS_COMPONENT_TARGET} PUBLIC + ${LCD_IFACE_TARGET} + log) + +# Display status +message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) +message(STATUS "*******************************************************") +message(STATUS "Library : " ${LCD_STUBS_COMPONENT_TARGET}) +message(STATUS "*******************************************************")
\ No newline at end of file diff --git a/source/hal/profiles/bare-metal/data_presentation/lcd/include/lcd_img.h b/source/hal/source/components/lcd/include/lcd_img.h index b447767..b447767 100644 --- a/source/hal/profiles/bare-metal/data_presentation/lcd/include/lcd_img.h +++ b/source/hal/source/components/lcd/include/lcd_img.h diff --git a/source/hal/platform/mps3/include/glcd_mps3.h b/source/hal/source/components/lcd/source/glcd.h index 5cb5a54..a54c6d0 100644 --- a/source/hal/platform/mps3/include/glcd_mps3.h +++ b/source/hal/source/components/lcd/source/glcd.h @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef GLCD_MPS3_H -#define GLCD_MPS3_H +#ifndef GLCD_H +#define GLCD_H #include <stdint.h> @@ -199,4 +199,4 @@ void GLCD_Box(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned short color); -#endif /* GLCD_MPS3_H */ +#endif /* GLCD_H */ diff --git a/source/hal/platform/mps3/source/font_9x15_h.h b/source/hal/source/components/lcd/source/glcd_mps3/font_9x15_h.h index bbfb930..bbfb930 100644 --- a/source/hal/platform/mps3/source/font_9x15_h.h +++ b/source/hal/source/components/lcd/source/glcd_mps3/font_9x15_h.h diff --git a/source/hal/platform/mps3/source/glcd_mps3.c b/source/hal/source/components/lcd/source/glcd_mps3/glcd_mps3.c index 9a375f2..c67483e 100644 --- a/source/hal/platform/mps3/source/glcd_mps3.c +++ b/source/hal/source/components/lcd/source/glcd_mps3/glcd_mps3.c @@ -14,13 +14,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "glcd_mps3.h" +#include "glcd.h" #include "log_macros.h" #include "font_9x15_h.h" -#include "smm_mps3.h" -#include "peripheral_memmap.h" /* Peripheral memory map definitions. */ +#define CLCD_CS_Pos 0 +#define CLCD_CS_Msk (1UL<<CLCD_CS_Pos) +#define SHIELD_0_nCS_Pos 1 +#define SHIELD_0_nCS_Msk (1UL<<SHIELD_0_nCS_Pos) +#define SHIELD_1_nCS_Pos 2 +#define SHIELD_1_nCS_Msk (1UL<<SHIELD_1_nCS_Pos) +#define CLCD_RESET_Pos 3 +#define CLCD_RESET_Msk (1UL<<CLCD_RESET_Pos) +#define CLCD_RS_Pos 4 +#define CLCD_RS_Msk (1UL<<CLCD_RS_Pos) +#define CLCD_RD_Pos 5 +#define CLCD_RD_Msk (1UL<<CLCD_RD_Pos) +#define CLCD_BL_Pos 6 +#define CLCD_BL_Msk (1UL<<CLCD_BL_Pos) /*-------------- CLCD Controller Internal Register addresses ----------------*/ #define CHAR_COM ((volatile unsigned int *)(CLCD_CONFIG_BASE + 0x000)) diff --git a/source/hal/platform/simple/source/stubs_glcd.c b/source/hal/source/components/lcd/source/glcd_stubs/glcd_stubs.c index d843cf4..5df1522 100644 --- a/source/hal/platform/simple/source/stubs_glcd.c +++ b/source/hal/source/components/lcd/source/glcd_stubs/glcd_stubs.c @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "stubs/glcd.h" +#include "glcd.h" #include "log_macros.h" #include <inttypes.h> diff --git a/source/hal/profiles/bare-metal/data_presentation/lcd/lcd_img.c b/source/hal/source/components/lcd/source/lcd_img.c index 6e05f29..e3921a9 100644 --- a/source/hal/profiles/bare-metal/data_presentation/lcd/lcd_img.c +++ b/source/hal/source/components/lcd/source/lcd_img.c @@ -17,7 +17,7 @@ #include "lcd_img.h" #include "log_macros.h" -#include "platform_drivers.h" +#include "glcd.h" #include <string.h> #include <assert.h> diff --git a/source/hal/components/ethosu_npu_init/CMakeLists.txt b/source/hal/source/components/npu/CMakeLists.txt index 59f32bd..804fb45 100644 --- a/source/hal/components/ethosu_npu_init/CMakeLists.txt +++ b/source/hal/source/components/npu/CMakeLists.txt @@ -20,7 +20,7 @@ ######################################################### cmake_minimum_required(VERSION 3.15.6) -set(ETHOS_U_NPU_INIT_COMPONENT ethosu_npu_init_component) +set(ETHOS_U_NPU_INIT_COMPONENT ethos_u_npu) project(${ETHOS_U_NPU_INIT_COMPONENT} DESCRIPTION "Ethos-U NPU initialization library" LANGUAGES C CXX ASM) @@ -85,16 +85,18 @@ target_include_directories(${ETHOS_U_NPU_INIT_COMPONENT} ## Component sources target_sources(${ETHOS_U_NPU_INIT_COMPONENT} PRIVATE - ethosu_npu_init.c) + ethosu_npu_init.c + ethosu_cpu_cache.c) ## Add dependencies: target_link_libraries(${ETHOS_U_NPU_INIT_COMPONENT} PUBLIC - cmsis_device + cmsis_device_cpu_header ethosu_core_driver log) target_compile_definitions(${ETHOS_U_NPU_INIT_COMPONENT} PUBLIC + ARM_NPU ${ETHOS_U_NPU_MEMORY_MODE_FLAG}) # Display status diff --git a/source/hal/source/components/npu/ethosu_cpu_cache.c b/source/hal/source/components/npu/ethosu_cpu_cache.c new file mode 100644 index 0000000..13f6f0a --- /dev/null +++ b/source/hal/source/components/npu/ethosu_cpu_cache.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ethosu_cpu_cache.h" + +#include "RTE_Components.h" /* For CPU related defintiions */ +#include "ethosu_driver.h" /* Arm Ethos-U driver header */ +#include "log_macros.h" /* Logging macros */ + +void ethosu_flush_dcache(uint32_t *p, size_t bytes) +{ +#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if (SCB->CCR & SCB_CCR_DC_Msk) { + if (p) { + SCB_CleanDCache_by_Addr((void *) p, (int32_t) bytes); + } else { + SCB_CleanDCache(); + } + } +#else + UNUSED(p); + UNUSED(bytes); +#endif /* defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) */ +} + +void ethosu_invalidate_dcache(uint32_t *p, size_t bytes) +{ +#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if (SCB->CCR & SCB_CCR_DC_Msk) { + if (p) { + SCB_InvalidateDCache_by_Addr((void *) p, (int32_t) bytes); + } else { + SCB_InvalidateDCache(); + } + } +#else + UNUSED(p); + UNUSED(bytes); +#endif /* defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) */ +} diff --git a/source/hal/components/ethosu_npu_init/ethosu_npu_init.c b/source/hal/source/components/npu/ethosu_npu_init.c index 161d613..9ccd887 100644 --- a/source/hal/components/ethosu_npu_init/ethosu_npu_init.c +++ b/source/hal/source/components/npu/ethosu_npu_init.c @@ -33,12 +33,12 @@ static uint8_t cache_arena[ETHOS_U_CACHE_BUF_SZ] CACHE_BUF_ATTRIBUTE; static uint8_t *cache_arena = NULL; #endif /* defined (ETHOS_U_CACHE_BUF_SZ) && (ETHOS_U_CACHE_BUF_SZ > 0) */ -uint8_t *get_cache_arena() +static uint8_t *get_cache_arena() { return cache_arena; } -size_t get_cache_arena_size() +static size_t get_cache_arena_size() { #if defined(ETHOS_U_CACHE_BUF_SZ) && (ETHOS_U_CACHE_BUF_SZ > 0) return sizeof(cache_arena); @@ -51,7 +51,7 @@ size_t get_cache_arena_size() * @brief Defines the Ethos-U interrupt handler: just a wrapper around the default * implementation. **/ -void arm_ethosu_npu_irq_handler(void) +static void arm_ethosu_npu_irq_handler(void) { /* Call the default interrupt handler from the NPU driver */ ethosu_irq_handler(ðosu_drv); @@ -60,7 +60,7 @@ void arm_ethosu_npu_irq_handler(void) /** * @brief Initialises the NPU IRQ **/ -void arm_ethosu_npu_irq_init(void) +static void arm_ethosu_npu_irq_init(void) { const IRQn_Type ethosu_irqnum = (IRQn_Type)EthosU_IRQn; diff --git a/source/hal/source/components/npu/include/ethosu_cpu_cache.h b/source/hal/source/components/npu/include/ethosu_cpu_cache.h new file mode 100644 index 0000000..9f21acf --- /dev/null +++ b/source/hal/source/components/npu/include/ethosu_cpu_cache.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ETHOSU_CPU_CACHE +#define ETHOSU_CPU_CACHE + +#include <stdint.h> +#include <stddef.h> + +/** + * @brief Flush/clean the data cache by address and size. Passing NULL as p argument + * expects the whole cache to be flushed. + * @param[in] p Pointer to the start address. + * @param[in] bytes Number of bytes to flush beginning at start address. + */ +void ethosu_flush_dcache(uint32_t *p, size_t bytes); + +/** + * @brief Invalidate the data cache by address and size. Passing NULL as p argument + * expects the whole cache to be invalidated. + * @param[in] p Pointer to the start address. + * @param[in] bytes Number of bytes to flush beginning at start address. + */ +void ethosu_invalidate_dcache(uint32_t *p, size_t bytes); + +#endif /* ETHOSU_CPU_CACHE */ diff --git a/source/hal/components/ethosu_npu_init/include/ethosu_mem_config.h b/source/hal/source/components/npu/include/ethosu_mem_config.h index aa0cfda..aa0cfda 100644 --- a/source/hal/components/ethosu_npu_init/include/ethosu_mem_config.h +++ b/source/hal/source/components/npu/include/ethosu_mem_config.h diff --git a/source/hal/components/ethosu_npu_init/include/ethosu_npu_init.h b/source/hal/source/components/npu/include/ethosu_npu_init.h index c562f6c..c562f6c 100644 --- a/source/hal/components/ethosu_npu_init/include/ethosu_npu_init.h +++ b/source/hal/source/components/npu/include/ethosu_npu_init.h diff --git a/source/hal/components/ethosu_ta_init/CMakeLists.txt b/source/hal/source/components/npu_ta/CMakeLists.txt index b5f94c1..fdda723 100644 --- a/source/hal/components/ethosu_ta_init/CMakeLists.txt +++ b/source/hal/source/components/npu_ta/CMakeLists.txt @@ -19,8 +19,13 @@ # Ethos-U NPU timing adapter initialization library # ######################################################### +# Timing adapter component is only available on certain implementations +# on FPGA and FVP where it is necessary to run bandwidth and latency +# sweeps on the Arm Ethos-U NPUs. The wrapper library here provides an +# easy way to add initialisation of the timing adapter block. + cmake_minimum_required(VERSION 3.15.6) -set(ETHOS_U_NPU_TA_COMPONENT ethosu_ta_init_component) +set(ETHOS_U_NPU_TA_COMPONENT ethos_u_ta) project(${ETHOS_U_NPU_TA_COMPONENT} DESCRIPTION "Ethos-U NPU timing adapter initialization library" LANGUAGES C CXX ASM) @@ -55,6 +60,11 @@ target_sources(${ETHOS_U_NPU_TA_COMPONENT} PRIVATE ethosu_ta_init.c) +## Compile definitions +target_compile_definitions(${ETHOS_U_NPU_TA_COMPONENT} + PUBLIC + ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) + ## Add dependencies target_link_libraries(${ETHOS_U_NPU_TA_COMPONENT} PUBLIC timing_adapter diff --git a/source/hal/components/ethosu_ta_init/cmake/templates/timing_adapter_settings.template b/source/hal/source/components/npu_ta/cmake/templates/timing_adapter_settings.template index 5b6c43d..5b6c43d 100644 --- a/source/hal/components/ethosu_ta_init/cmake/templates/timing_adapter_settings.template +++ b/source/hal/source/components/npu_ta/cmake/templates/timing_adapter_settings.template diff --git a/source/hal/components/ethosu_ta_init/ethosu_ta_init.c b/source/hal/source/components/npu_ta/ethosu_ta_init.c index 323ab73..323ab73 100644 --- a/source/hal/components/ethosu_ta_init/ethosu_ta_init.c +++ b/source/hal/source/components/npu_ta/ethosu_ta_init.c diff --git a/source/hal/components/ethosu_ta_init/include/ethosu_ta_init.h b/source/hal/source/components/npu_ta/include/ethosu_ta_init.h index 7e6df6c..7e6df6c 100644 --- a/source/hal/components/ethosu_ta_init/include/ethosu_ta_init.h +++ b/source/hal/source/components/npu_ta/include/ethosu_ta_init.h diff --git a/source/hal/source/components/stdout/CMakeLists.txt b/source/hal/source/components/stdout/CMakeLists.txt new file mode 100644 index 0000000..f1e26ff --- /dev/null +++ b/source/hal/source/components/stdout/CMakeLists.txt @@ -0,0 +1,110 @@ +#---------------------------------------------------------------------------- +# Copyright (c) 2022 Arm Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#---------------------------------------------------------------------------- + +######################################################### +# Wrapper for enabling stdout and stderr facility # +######################################################### +# This is a wrapper around the UART module for CMSDK # +# and PL011 UART drivers with retarget functions. # +######################################################### + +cmake_minimum_required(VERSION 3.15.6) + +project(stdout + DESCRIPTION "Standard output and err redirection over UART" + LANGUAGES C CXX) + + +set(STDOUT_RETARGET OFF CACHE BOOL "Retarget stdout/err to UART") + +# Interface library for standard output: +set(STDOUT_IFACE_TARGET stdout_iface) +add_library(${STDOUT_IFACE_TARGET} INTERFACE) +target_include_directories(${STDOUT_IFACE_TARGET} INTERFACE include) + +if (STDOUT_RETARGET) + + set(STDOUT_COMPONENT_CMSDK stdout_retarget_cmsdk) + set(STDOUT_COMPONENT_PL011 stdout_retarget_pl011) + + add_library(${STDOUT_COMPONENT_CMSDK} STATIC) + add_library(${STDOUT_COMPONENT_PL011} STATIC) + + # Check prerequisites + ## Core platform directory is required to add the UART library project. + if (NOT DEFINED CORE_PLATFORM_DIR) + message(FATAL_ERROR "CORE_PLATFORM_DIR undefined") + endif() + + ## UART0_BASE is the base address for UART configuration. The platform + ## should define it prior to including this library. + if (NOT DEFINED UART0_BASE) + message(WARNING "UART0_BASE undefined, default will be used.") + endif() + + ## Platform component: UART + add_subdirectory(${CORE_PLATFORM_DIR}/drivers/uart ${CMAKE_BINARY_DIR}/uart) + + ## Component sources - public + target_sources(${STDOUT_COMPONENT_CMSDK} + PUBLIC + source/retarget.c) + + ## Component sources - public + target_sources(${STDOUT_COMPONENT_PL011} + PUBLIC + source/retarget.c) + + # Link + target_link_libraries(${STDOUT_COMPONENT_CMSDK} + PUBLIC + ${STDOUT_IFACE_TARGET} + ethosu_uart_cmsdk_apb) + + target_link_libraries(${STDOUT_COMPONENT_PL011} + PUBLIC + ${STDOUT_IFACE_TARGET} + ethosu_uart_pl011) + + # Display status + message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) + message(STATUS "*******************************************************") + message(STATUS "Library: " ${STDOUT_COMPONENT_CMSDK}) + message(STATUS "Library: " ${STDOUT_COMPONENT_PL011}) + message(STATUS "*******************************************************") + +else() + + # Create static library for retarget (stdout/err over UART) + set(STDOUT_COMPONENT stdout) + add_library(${STDOUT_COMPONENT} STATIC) + + ## Component sources - public + target_sources(${STDOUT_COMPONENT} + PUBLIC + source/user_input.c) + + target_link_libraries(${STDOUT_COMPONENT} + PUBLIC + ${STDOUT_IFACE_TARGET}) + + # Display status + message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) + message(STATUS "*******************************************************") + message(STATUS "Library: " ${STDOUT_COMPONENT}) + message(STATUS "*******************************************************") +endif() diff --git a/source/hal/source/components/stdout/include/user_input.h b/source/hal/source/components/stdout/include/user_input.h new file mode 100644 index 0000000..e76b418 --- /dev/null +++ b/source/hal/source/components/stdout/include/user_input.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef STDOUT_USER_INPUT_H +#define STDOUT_USER_INPUT_H + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned int GetLine(char *user_input, unsigned int size); + +#ifdef __cplusplus +} +#endif + +#endif /* STDOUT_USER_INPUT_H */ diff --git a/source/hal/profiles/bare-metal/bsp/retarget.c b/source/hal/source/components/stdout/source/retarget.c index ac9b282..ac9b282 100644 --- a/source/hal/profiles/bare-metal/bsp/retarget.c +++ b/source/hal/source/components/stdout/source/retarget.c diff --git a/source/hal/source/components/stdout/source/user_input.c b/source/hal/source/components/stdout/source/user_input.c new file mode 100644 index 0000000..e5fe1b9 --- /dev/null +++ b/source/hal/source/components/stdout/source/user_input.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> + +unsigned int GetLine(char *user_input, unsigned int size) +{ + if (NULL != fgets(user_input, size, stdin)) { + return 1; + } + return 0; +} + +#ifdef __cplusplus +} +#endif diff --git a/source/hal/profiles/bare-metal/data_acquisition/data_acq.c b/source/hal/source/data_acq.c index 84d80a6..ec6c725 100644 --- a/source/hal/profiles/bare-metal/data_acquisition/data_acq.c +++ b/source/hal/source/data_acq.c @@ -18,7 +18,6 @@ #include "log_macros.h" #include "platform_drivers.h" -#include "uart_stdout.h" #include <assert.h> #include <stdlib.h> diff --git a/source/hal/profiles/bare-metal/data_presentation/data_psn.c b/source/hal/source/data_psn.c index de088d7..de088d7 100644 --- a/source/hal/profiles/bare-metal/data_presentation/data_psn.c +++ b/source/hal/source/data_psn.c diff --git a/source/hal/hal.c b/source/hal/source/hal.c index 2715a17..2715a17 100644 --- a/source/hal/hal.c +++ b/source/hal/source/hal.c diff --git a/source/hal/platform/mps3/CMakeLists.txt b/source/hal/source/platform/mps3/CMakeLists.txt index 7ef4ed4..8bd51dc 100644 --- a/source/hal/platform/mps3/CMakeLists.txt +++ b/source/hal/source/platform/mps3/CMakeLists.txt @@ -41,6 +41,14 @@ endif() ## Include the platform cmake descriptor file include(${PLATFORM_CMAKE_DESCRIPTOR_FILE}) +# Define target specific base addresses here (before adding the components) +if (TARGET_SUBSYSTEM STREQUAL sse-300) + set(UART0_BASE "0x49303000" CACHE STRING "UART base address") + set(UART0_BAUDRATE "115200" CACHE STRING "UART baudrate") + set(SYSTEM_CORE_CLOCK "25000000" CACHE STRING "System peripheral clock (Hz)") + set(CLCD_CONFIG_BASE "0x4930A000" CACHE STRING "LCD configuration base address") +endif() + # 3. Generate sources: if (NOT DEFINED SOURCE_GEN_DIR) set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp) @@ -54,7 +62,7 @@ configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h" configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h") configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h") -# 4. Create static library +# Create static library add_library(${PLATFORM_DRIVERS_TARGET} STATIC) ## Include directories - private @@ -71,56 +79,53 @@ target_include_directories(${PLATFORM_DRIVERS_TARGET} ## Platform sources target_sources(${PLATFORM_DRIVERS_TARGET} PRIVATE - source/device_mps3.c source/timer_mps3.c - source/platform_drivers.c - source/glcd_mps3.c) + source/platform_drivers.c) + +## Compile definitions +target_compile_definitions(${PLATFORM_DRIVERS_TARGET} + PUBLIC + ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ}) ## Directory for additional components required by MPS3: if (NOT DEFINED COMPONENTS_DIR) set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components) endif() -## This target provides the following definitions for MPS3 specific behaviour -## TODO: We should aim to remove this now with platform refactoring.. -target_compile_definitions(${PLATFORM_DRIVERS_TARGET} - PUBLIC - MPS3_PLATFORM - ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ}) +## Platform component: cmsis_device (provides generic Cortex-M start up library) +add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device) + +## Platform component: stdout +set(STDOUT_RETARGET ON CACHE BOOL "Retarget stdout/err to UART") +add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout) -## Platform component: uart -add_subdirectory(${DEPENDENCY_ROOT_DIR}/core-platform/drivers/uart ${CMAKE_BINARY_DIR}/uart) +## Platform component: lcd +add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd) # Add dependencies: target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC log cmsis_device - ethosu_uart_cmsdk_apb) + lcd_mps3 + $<IF:$<BOOL:STDOUT_RETARGET>,stdout_retarget_cmsdk,stdout>) # If Ethos-U is enabled, we need the driver library too if (ETHOS_U_NPU_ENABLED) - target_compile_definitions(${PLATFORM_DRIVERS_TARGET} - PUBLIC - ARM_NPU) - ## Platform component: Ethos-U initialization - add_subdirectory(${COMPONENTS_DIR}/ethosu_npu_init ${CMAKE_BINARY_DIR}/ethosu_npu_init) + add_subdirectory(${COMPONENTS_DIR}/npu ${CMAKE_BINARY_DIR}/npu) target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC - ethosu_npu_init_component) + ethos_u_npu) if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) ## Platform component: Ethos-U timing adapter initialization - add_subdirectory(${COMPONENTS_DIR}/ethosu_ta_init ${CMAKE_BINARY_DIR}/ethosu_ta_init) + add_subdirectory(${COMPONENTS_DIR}/npu_ta ${CMAKE_BINARY_DIR}/npu_ta) target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC - ethosu_ta_init_component) - target_compile_definitions(${PLATFORM_DRIVERS_TARGET} - PUBLIC - ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) + ethos_u_ta) endif() endif() diff --git a/source/hal/platform/mps3/cmake/subsystem-profiles/sse-300.cmake b/source/hal/source/platform/mps3/cmake/subsystem-profiles/sse-300.cmake index eec6fde..eec6fde 100644 --- a/source/hal/platform/mps3/cmake/subsystem-profiles/sse-300.cmake +++ b/source/hal/source/platform/mps3/cmake/subsystem-profiles/sse-300.cmake diff --git a/source/hal/platform/mps3/cmake/templates/mem_regions.h.template b/source/hal/source/platform/mps3/cmake/templates/mem_regions.h.template index 72978ce..72978ce 100644 --- a/source/hal/platform/mps3/cmake/templates/mem_regions.h.template +++ b/source/hal/source/platform/mps3/cmake/templates/mem_regions.h.template diff --git a/source/hal/platform/mps3/cmake/templates/peripheral_irqs.h.template b/source/hal/source/platform/mps3/cmake/templates/peripheral_irqs.h.template index 7696e13..7696e13 100644 --- a/source/hal/platform/mps3/cmake/templates/peripheral_irqs.h.template +++ b/source/hal/source/platform/mps3/cmake/templates/peripheral_irqs.h.template diff --git a/source/hal/platform/mps3/cmake/templates/peripheral_memmap.h.template b/source/hal/source/platform/mps3/cmake/templates/peripheral_memmap.h.template index d7f0b3a..d7f0b3a 100644 --- a/source/hal/platform/mps3/cmake/templates/peripheral_memmap.h.template +++ b/source/hal/source/platform/mps3/cmake/templates/peripheral_memmap.h.template diff --git a/source/hal/platform/mps3/cmake/templates/timing_adapter_settings.template b/source/hal/source/platform/mps3/cmake/templates/timing_adapter_settings.template index d5e202a..d5e202a 100644 --- a/source/hal/platform/mps3/cmake/templates/timing_adapter_settings.template +++ b/source/hal/source/platform/mps3/cmake/templates/timing_adapter_settings.template diff --git a/source/hal/platform/mps3/include/platform_drivers.h b/source/hal/source/platform/mps3/include/platform_drivers.h index a706ed4..8b699d5 100644 --- a/source/hal/platform/mps3/include/platform_drivers.h +++ b/source/hal/source/platform/mps3/include/platform_drivers.h @@ -21,13 +21,10 @@ #include "log_macros.h" /* Logging related helpers. */ /* Platform components */ -#include "timer_mps3.h" /* Timer functions. */ #include "RTE_Components.h" /* For CPU related defintiions */ -#include "glcd_mps3.h" /* LCD functions. */ - -/** Platform definitions. TODO: These should be removed. */ -#include "peripheral_memmap.h" /* Peripheral memory map definitions. */ -#include "peripheral_irqs.h" /* IRQ numbers for this platform. */ +#include "timer_mps3.h" /* Timer functions. */ +#include "user_input.h" /* User input function */ +#include "lcd_img.h" /* LCD functions. */ /** * @brief Initialises the platform components. diff --git a/source/hal/platform/mps3/include/timer_mps3.h b/source/hal/source/platform/mps3/include/timer_mps3.h index b5db722..e1faf69 100644 --- a/source/hal/platform/mps3/include/timer_mps3.h +++ b/source/hal/source/platform/mps3/include/timer_mps3.h @@ -24,13 +24,20 @@ typedef struct _mps3_time_counter { uint32_t counter_1Hz; uint32_t counter_100Hz; - /* Running at FPGA clock rate. See GetMPS3CoreClock(). */ + /* Running at FPGA clock rate. See get_mps3_core_clock(). */ uint32_t counter_fpga; /* Running at processor core's internal clock rate, triggered by SysTick. */ uint64_t counter_systick; } base_time_counter; + +/** + * @brief Gets the MPS3 core clock + * @return Clock rate in Hz expressed as 32 bit unsigned integer. + */ +uint32_t get_mps3_core_clock(void); + /** * @brief Resets the counters. */ diff --git a/source/hal/platform/mps3/source/device_mps3.h b/source/hal/source/platform/mps3/source/device_mps3.h index 9447c07..9447c07 100644 --- a/source/hal/platform/mps3/source/device_mps3.h +++ b/source/hal/source/platform/mps3/source/device_mps3.h diff --git a/source/hal/platform/mps3/source/platform_drivers.c b/source/hal/source/platform/mps3/source/platform_drivers.c index 00afb78..5de41c2 100644 --- a/source/hal/platform/mps3/source/platform_drivers.c +++ b/source/hal/source/platform/mps3/source/platform_drivers.c @@ -18,10 +18,8 @@ #include "platform_drivers.h" #include "log_macros.h" /* Logging functions */ -#include "device_mps3.h" /* FPGA level definitions and functions. */ #include "uart_stdout.h" /* stdout over UART. */ - -#include "smm_mps3.h" /* Memory map for MPS3. */ +#include "smm_mps3.h" /* Memory map for MPS3. */ #include <string.h> /* For strncpy */ @@ -61,8 +59,7 @@ int platform_init(void) #if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) /* If the platform has timing adapter blocks along with Ethos-U core * block, initialise them here. */ - if (0 != (err = arm_ethosu_timing_adapter_init())) - { + if (0 != (err = arm_ethosu_timing_adapter_init())) { return err; } #endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */ @@ -70,8 +67,7 @@ int platform_init(void) int state; /* If Arm Ethos-U NPU is to be used, we initialise it here */ - if (0 != (state = arm_ethosu_npu_init())) - { + if (0 != (state = arm_ethosu_npu_init())) { return state; } @@ -110,14 +106,14 @@ static int verify_platform(void) /* Initialise the LEDs as the switches are */ MPS3_FPGAIO->LED = MPS3_FPGAIO->SWITCHES & 0xFF; - info("Processor internal clock: %" PRIu32 "Hz\n", GetMPS3CoreClock()); + info("Processor internal clock: %" PRIu32 "Hz\n", get_mps3_core_clock()); /* Get revision information from various registers */ rev = MPS3_SCC->CFG_REG4; fpgaid = MPS3_SCC->SCC_ID; aid = MPS3_SCC->SCC_AID; apnote = EXTRACT_BITS(fpgaid, 15, 4); - fpga_clk = GetMPS3CoreClock(); + fpga_clk = get_mps3_core_clock(); info("V2M-MPS3 revision %c\n\n", (char)(rev + ascii_A)); info("Application Note AN%" PRIx32 ", Revision %c\n", apnote, diff --git a/source/hal/platform/mps3/source/smm_mps3.h b/source/hal/source/platform/mps3/source/smm_mps3.h index 8d5614a..8d5614a 100644 --- a/source/hal/platform/mps3/source/smm_mps3.h +++ b/source/hal/source/platform/mps3/source/smm_mps3.h diff --git a/source/hal/platform/mps3/source/timer_mps3.c b/source/hal/source/platform/mps3/source/timer_mps3.c index 6da026f..3511883 100644 --- a/source/hal/platform/mps3/source/timer_mps3.c +++ b/source/hal/source/platform/mps3/source/timer_mps3.c @@ -17,7 +17,6 @@ #include "timer_mps3.h" #include "log_macros.h" -#include "device_mps3.h" #include "smm_mps3.h" /* Memory map for MPS3. */ static uint64_t cpu_cycle_count = 0; /* 64-bit cpu cycle counter */ @@ -94,7 +93,7 @@ uint32_t get_duration_milliseconds(base_time_counter *start, uint32_t get_duration_microseconds(base_time_counter *start, base_time_counter *end) { - const int divisor = GetMPS3CoreClock()/1000000; + const int divisor = get_mps3_core_clock()/1000000; uint32_t time_elapsed = 0; if (end->counter_fpga > start->counter_fpga) { time_elapsed = (end->counter_fpga - start->counter_fpga)/divisor; @@ -144,12 +143,13 @@ static uint64_t Get_SysTick_Cycle_Count(void) return cpu_cycle_count + (SysTick->LOAD - systick_val); } + /** * SysTick initialisation */ static int Init_SysTick(void) { - const uint32_t ticks_10ms = GetMPS3CoreClock()/100 + 1; + const uint32_t ticks_10ms = get_mps3_core_clock()/100 + 1; int err = 0; /* Reset CPU cycle count value. */ @@ -172,3 +172,22 @@ static int Init_SysTick(void) return err; } + +uint32_t get_mps3_core_clock(void) +{ + const uint32_t default_clock = 32000000 /* 32 MHz clock */; + static int warned_once = 0; + if (0 != MPS3_SCC->CFG_ACLK) { + if (default_clock != MPS3_SCC->CFG_ACLK) { + warn("System clock is different to the MPS3 config set clock.\n"); + } + return MPS3_SCC->CFG_ACLK; + } + + if (!warned_once) { + warn("MPS3_SCC->CFG_ACLK reads 0. Assuming default clock of %" PRIu32 "\n", + default_clock); + warned_once = 1; + } + return default_clock; +}
\ No newline at end of file diff --git a/source/hal/platform/native/CMakeLists.txt b/source/hal/source/platform/native/CMakeLists.txt index 0b9fee1..fef5d5e 100644 --- a/source/hal/platform/native/CMakeLists.txt +++ b/source/hal/source/platform/native/CMakeLists.txt @@ -32,7 +32,6 @@ if (${CMAKE_CROSSCOMPILING}) message(FATAL_ERROR "Native drivers not available when cross-compiling.") endif() - # Create static library add_library(${PLATFORM_DRIVERS_TARGET} STATIC) @@ -46,8 +45,29 @@ target_sources(${PLATFORM_DRIVERS_TARGET} PRIVATE source/platform_drivers.c) +## Platform definitions: +target_compile_definitions(${PLATFORM_DRIVERS_TARGET} + PUBLIC + ACTIVATION_BUF_SRAM_SZ=0) + +## Platform component directory +if (NOT DEFINED COMPONENTS_DIR) + set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components) +endif() + +## Platform component: stdout +set(STDOUT_RETARGET OFF CACHE BOOL "Retarget stdout/err to UART") +add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout) + +## Platform component: lcd +add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd) + # Add dependencies: -target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC log) +target_link_libraries(${PLATFORM_DRIVERS_TARGET} + PUBLIC + log + stdout + lcd_stubs) # Display status: message(STATUS "*******************************************************") diff --git a/source/hal/platform/native/include/platform_drivers.h b/source/hal/source/platform/native/include/platform_drivers.h index ca6b6e0..d93e31c 100644 --- a/source/hal/platform/native/include/platform_drivers.h +++ b/source/hal/source/platform/native/include/platform_drivers.h @@ -19,6 +19,8 @@ #define PLATFORM_DRIVERS_H #include "log_macros.h" /* Logging related helpers. */ +#include "lcd_img.h" /* LCD functions */ +#include "user_input.h" /* User input function */ /** * @brief Initialises the platform components. diff --git a/source/hal/platform/native/source/platform_drivers.c b/source/hal/source/platform/native/source/platform_drivers.c index 10db99a..10db99a 100644 --- a/source/hal/platform/native/source/platform_drivers.c +++ b/source/hal/source/platform/native/source/platform_drivers.c diff --git a/source/hal/platform/simple/CMakeLists.txt b/source/hal/source/platform/simple/CMakeLists.txt index df4df00..c8d4953 100644 --- a/source/hal/platform/simple/CMakeLists.txt +++ b/source/hal/source/platform/simple/CMakeLists.txt @@ -39,6 +39,12 @@ endif() ## Include the platform cmake descriptor file include(${PLATFORM_CMAKE_DESCRIPTOR_FILE}) +# Define target specific values here (before adding the components) +set(UART0_BASE "0x49303000" CACHE STRING "UART base address") +set(UART0_BAUDRATE "115200" CACHE STRING "UART baudrate") +set(SYSTEM_CORE_CLOCK "25000000" CACHE STRING "System peripheral clock (Hz)") +set(ACTIVATION_BUF_SRAM_SZ "0x200000" CACHE STRING "Maximum SRAM size for activation buffers") + # 3. Generate sources: if (NOT DEFINED SOURCE_GEN_DIR) set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp) @@ -64,7 +70,6 @@ target_include_directories(${PLATFORM_DRIVERS_TARGET} ## Platform sources target_sources(${PLATFORM_DRIVERS_TARGET} PRIVATE - source/stubs_glcd.c source/timer_simple_platform.c source/platform_drivers.c) @@ -73,8 +78,16 @@ if (NOT DEFINED COMPONENTS_DIR) set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components) endif() -## Platform component: uart -add_subdirectory(${DEPENDENCY_ROOT_DIR}/core-platform/drivers/uart ${CMAKE_BINARY_DIR}/uart) + +## Platform component: cmsis_device (provides generic Cortex-M start up library) +add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device) + +## Platform component: stdout +set(STDOUT_RETARGET ON CACHE BOOL "Retarget stdout/err to UART") +add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout) + +## Platform component: lcd +add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd) ## Compile defs target_compile_definitions(${PLATFORM_DRIVERS_TARGET} @@ -85,32 +98,26 @@ target_compile_definitions(${PLATFORM_DRIVERS_TARGET} target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC cmsis_device log - ethosu_uart_pl011) + lcd_stubs + $<IF:$<BOOL:STDOUT_RETARGET>,stdout_retarget_pl011,stdout>) # If Ethos-U is enabled, we need the driver library too if (ETHOS_U_NPU_ENABLED) - target_compile_definitions(${PLATFORM_DRIVERS_TARGET} - PUBLIC - ARM_NPU) - ## Platform component: Ethos-U initialization - add_subdirectory(${COMPONENTS_DIR}/ethosu_npu_init ${CMAKE_BINARY_DIR}/ethosu_npu_init) + add_subdirectory(${COMPONENTS_DIR}/npu ${CMAKE_BINARY_DIR}/npu) target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC - ethosu_npu_init_component) + ethos_u_npu) if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) ## Platform component: Ethos-U timing apadpter initialization - add_subdirectory(${COMPONENTS_DIR}/ethosu_ta_init ${CMAKE_BINARY_DIR}/ethosu_ta_init) + add_subdirectory(${COMPONENTS_DIR}/npu_ta ${CMAKE_BINARY_DIR}/npu_ta) target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC - ethosu_ta_init_component) - target_compile_definitions(${PLATFORM_DRIVERS_TARGET} - PUBLIC - ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) + ethos_u_ta) endif() endif() diff --git a/source/hal/platform/simple/cmake/subsystem-profiles/simple_platform.cmake b/source/hal/source/platform/simple/cmake/subsystem-profiles/simple_platform.cmake index e6cfef3..e6cfef3 100644 --- a/source/hal/platform/simple/cmake/subsystem-profiles/simple_platform.cmake +++ b/source/hal/source/platform/simple/cmake/subsystem-profiles/simple_platform.cmake diff --git a/source/hal/platform/simple/cmake/templates/mem_regions.h.template b/source/hal/source/platform/simple/cmake/templates/mem_regions.h.template index 72978ce..72978ce 100644 --- a/source/hal/platform/simple/cmake/templates/mem_regions.h.template +++ b/source/hal/source/platform/simple/cmake/templates/mem_regions.h.template diff --git a/source/hal/platform/simple/cmake/templates/peripheral_irqs.h.template b/source/hal/source/platform/simple/cmake/templates/peripheral_irqs.h.template index 8126cb4..8126cb4 100644 --- a/source/hal/platform/simple/cmake/templates/peripheral_irqs.h.template +++ b/source/hal/source/platform/simple/cmake/templates/peripheral_irqs.h.template diff --git a/source/hal/platform/simple/cmake/templates/peripheral_memmap.h.template b/source/hal/source/platform/simple/cmake/templates/peripheral_memmap.h.template index 2bfaafc..2bfaafc 100644 --- a/source/hal/platform/simple/cmake/templates/peripheral_memmap.h.template +++ b/source/hal/source/platform/simple/cmake/templates/peripheral_memmap.h.template diff --git a/source/hal/platform/simple/cmake/templates/timing_adapter_settings.template b/source/hal/source/platform/simple/cmake/templates/timing_adapter_settings.template index d5e202a..d5e202a 100644 --- a/source/hal/platform/simple/cmake/templates/timing_adapter_settings.template +++ b/source/hal/source/platform/simple/cmake/templates/timing_adapter_settings.template diff --git a/source/hal/platform/simple/include/platform_drivers.h b/source/hal/source/platform/simple/include/platform_drivers.h index c1a6c6a..5f2ed33 100644 --- a/source/hal/platform/simple/include/platform_drivers.h +++ b/source/hal/source/platform/simple/include/platform_drivers.h @@ -21,13 +21,10 @@ #include "log_macros.h" /* Logging related helpers. */ /* Platform components */ -#include "stubs/glcd.h" /* LCD stubs to support use cases that use LCD */ -#include "timer_simple_platform.h" /* timer implementation */ #include "RTE_Components.h" /* For CPU related defintiions */ - -/** Platform definitions. TODO: These should be removed. */ -#include "peripheral_memmap.h" /* Peripheral memory map definitions. */ -#include "peripheral_irqs.h" /* IRQ numbers for this platform. */ +#include "timer_simple_platform.h" /* timer implementation */ +#include "user_input.h" /* User input function */ +#include "lcd_img.h" /* LCD functions */ /** * @brief Initialises the platform components. diff --git a/source/hal/platform/simple/include/timer_simple_platform.h b/source/hal/source/platform/simple/include/timer_simple_platform.h index 683a207..683a207 100644 --- a/source/hal/platform/simple/include/timer_simple_platform.h +++ b/source/hal/source/platform/simple/include/timer_simple_platform.h diff --git a/source/hal/platform/simple/source/platform_drivers.c b/source/hal/source/platform/simple/source/platform_drivers.c index aae867c..19c0057 100644 --- a/source/hal/platform/simple/source/platform_drivers.c +++ b/source/hal/source/platform/simple/source/platform_drivers.c @@ -18,6 +18,9 @@ #include "platform_drivers.h" #include "uart_stdout.h" +#include "peripheral_memmap.h" + + #include <string.h> #if defined(ARM_NPU) diff --git a/source/hal/platform/simple/source/timer_simple_platform.c b/source/hal/source/platform/simple/source/timer_simple_platform.c index f7917b0..f7917b0 100644 --- a/source/hal/platform/simple/source/timer_simple_platform.c +++ b/source/hal/source/platform/simple/source/timer_simple_platform.c diff --git a/source/hal/profiles/bare-metal/timer/include/platform_timer.h b/source/hal/source/profiles/bare-metal/timer/include/platform_timer.h index dd3934e..dd3934e 100644 --- a/source/hal/profiles/bare-metal/timer/include/platform_timer.h +++ b/source/hal/source/profiles/bare-metal/timer/include/platform_timer.h diff --git a/source/hal/profiles/bare-metal/timer/platform_timer.c b/source/hal/source/profiles/bare-metal/timer/platform_timer.c index 0388198..0388198 100644 --- a/source/hal/profiles/bare-metal/timer/platform_timer.c +++ b/source/hal/source/profiles/bare-metal/timer/platform_timer.c diff --git a/source/hal/profiles/native/timer/include/platform_timer.h b/source/hal/source/profiles/native/timer/include/platform_timer.h index df7b493..df7b493 100644 --- a/source/hal/profiles/native/timer/include/platform_timer.h +++ b/source/hal/source/profiles/native/timer/include/platform_timer.h diff --git a/source/hal/profiles/native/timer/platform_timer.c b/source/hal/source/profiles/native/timer/platform_timer.c index c311125..c311125 100644 --- a/source/hal/profiles/native/timer/platform_timer.c +++ b/source/hal/source/profiles/native/timer/platform_timer.c |