alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021 Arm Limited. All rights reserved. |
| 3 | * SPDX-License-Identifier: Apache-2.0 |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | #ifndef PLATFORM_HAL_H |
| 18 | #define PLATFORM_HAL_H |
| 19 | |
| 20 | /** |
| 21 | * This file should present a C API for the main application logic to use |
| 22 | * and be indifferent to the lower level platform. In addition to this it |
| 23 | * will also need to be aware of the API exposed by data acquisition and |
| 24 | * data presentation modules. |
| 25 | */ |
| 26 | #include "hal_config.h" |
| 27 | |
| 28 | #ifdef __cplusplus |
| 29 | extern "C" { |
| 30 | #endif |
| 31 | |
| 32 | #include "data_acq.h" /* Data acquisition abstraction */ |
| 33 | #include "data_psn.h" /* Data presentation abstraction */ |
| 34 | #include "timer.h" /* Timer/profiler API */ |
| 35 | |
| 36 | /* Structure to define a platform context to be used by the application */ |
| 37 | typedef struct hal_platform_context { |
| 38 | int inited; /**< initialised */ |
| 39 | char plat_name[16]; /**< name of this platform */ |
| 40 | data_acq_module * data_acq; /**< data acquisition module pointer */ |
| 41 | data_psn_module * data_psn; /**< data presentation module pointer */ |
| 42 | platform_timer * timer; /**< timer */ |
| 43 | int (* platform_init)(); /**< pointer to platform initialisation function */ |
| 44 | void (* platform_release)(); /**< pointer to platform release function */ |
| 45 | } hal_platform; |
| 46 | |
| 47 | /** |
| 48 | * @brief Initialise the HAL structure based on compile time config. This |
| 49 | * should be called before any other function in this API. |
| 50 | * @param[in,out] platform Pointer to a pre-allocated platform struct. |
| 51 | * @param[in,out] data_acq Pointer to a pre-allocated data acquisition module. |
| 52 | * @param[in,out] data_psn Pointer to a pre-allocated data presentation module. |
| 53 | * @param[in,out] timer Pointer to a pre-allocated timer module. |
| 54 | * @return 0 if successful, error code otherwise. |
| 55 | **/ |
| 56 | int hal_init(hal_platform *platform, data_acq_module *data_acq, |
| 57 | data_psn_module *data_psn, platform_timer *timer); |
| 58 | |
| 59 | |
| 60 | /** |
| 61 | * @brief Initialise the HAL platform. This will go and initialise all the |
| 62 | * modules on the platform the application requires to run. |
| 63 | * @param[in] platform Pointer to a pre-allocated and initialised |
| 64 | * platform structure. |
| 65 | * @return 0 if successful, error code otherwise. |
| 66 | **/ |
| 67 | int hal_platform_init(hal_platform *platform); |
| 68 | |
| 69 | |
| 70 | /** |
| 71 | * @brief Release the HAL platform. This should release resources acquired. |
| 72 | * @param[in] platform pointer to a pre-allocated and initialised |
| 73 | * platform structure. |
| 74 | **/ |
| 75 | void hal_platform_release(hal_platform *platform); |
| 76 | |
| 77 | #ifdef __cplusplus |
| 78 | } |
| 79 | #endif |
| 80 | |
| 81 | #endif /* PLATFORM_HAL_H */ |