diff options
Diffstat (limited to 'source/application/hal/hal.c')
-rw-r--r-- | source/application/hal/hal.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/source/application/hal/hal.c b/source/application/hal/hal.c index 12bb7ef..53a304b 100644 --- a/source/application/hal/hal.c +++ b/source/application/hal/hal.c @@ -24,18 +24,39 @@ #if defined(ARM_NPU) +#include "ethosu_mem_config.h" /* Arm Ethos-U memory config */ #include "ethosu_driver.h" /* Arm Ethos-U driver header */ #include "timing_adapter.h" /* Arm Ethos-U timing adapter driver header */ #include "timing_adapter_settings.h" /* Arm Ethos-U timing adapter settings */ struct ethosu_driver ethosu_drv; /* Default Ethos-U device driver */ +#if defined(ETHOS_U_CACHE_BUF_SZ) && (ETHOS_U_CACHE_BUF_SZ > 0) + static uint8_t cache_arena[ETHOS_U_CACHE_BUF_SZ] CACHE_BUF_ATTRIBUTE; +#else /* defined (ETHOS_U_CACHE_BUF_SZ) && (ETHOS_U_CACHE_BUF_SZ > 0) */ + static uint8_t* cache_arena = NULL; +#endif /* defined (ETHOS_U_CACHE_BUF_SZ) && (ETHOS_U_CACHE_BUF_SZ > 0) */ + /** * @brief Initialises the Arm Ethos-U NPU * @return 0 if successful, error code otherwise **/ static int arm_npu_init(void); +static uint8_t * get_cache_arena() +{ + return cache_arena; +} + +static size_t get_cache_arena_size() +{ +#if defined(ETHOS_U_CACHE_BUF_SZ) && (ETHOS_U_CACHE_BUF_SZ > 0) + return sizeof(cache_arena); +#else /* defined (ETHOS_U_CACHE_BUF_SZ) && (ETHOS_U_CACHE_BUF_SZ > 0) */ + return 0; +#endif /* defined (ETHOS_U_CACHE_BUF_SZ) && (ETHOS_U_CACHE_BUF_SZ > 0) */ +} + #endif /* ARM_NPU */ int hal_init(hal_platform* platform, data_acq_module* data_acq, @@ -232,12 +253,12 @@ static int arm_npu_init(void) const void * ethosu_base_address = (void *)(SEC_ETHOS_U_NPU_BASE); if (0 != (err = ethosu_init( - ðosu_drv, /* Ethos-U driver device pointer */ - ethosu_base_address, /* Ethos-U NPU's base address. */ - NULL, /* Pointer to fast mem area - NULL for U55. */ - 0, /* Fast mem region size. */ - 1, /* Security enable. */ - 1))) { /* Privilege enable. */ + ðosu_drv, /* Ethos-U driver device pointer */ + ethosu_base_address, /* Ethos-U NPU's base address. */ + get_cache_arena(), /* Pointer to fast mem area - NULL for U55. */ + get_cache_arena_size(), /* Fast mem region size. */ + 1, /* Security enable. */ + 1))) { /* Privilege enable. */ printf_err("failed to initalise Ethos-U device\n"); return err; } @@ -266,4 +287,5 @@ static int arm_npu_init(void) return 0; } + #endif /* ARM_NPU */ |