blob: a192ea79f4def11a240c506b5cfb436cd8512609 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
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
29extern "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
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010036#include <inttypes.h>
37
alexander3c798932021-03-26 21:42:19 +000038/* Structure to define a platform context to be used by the application */
39typedef struct hal_platform_context {
40 int inited; /**< initialised */
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010041 char plat_name[64]; /**< name of this platform */
alexander3c798932021-03-26 21:42:19 +000042 data_acq_module * data_acq; /**< data acquisition module pointer */
43 data_psn_module * data_psn; /**< data presentation module pointer */
44 platform_timer * timer; /**< timer */
45 int (* platform_init)(); /**< pointer to platform initialisation function */
46 void (* platform_release)(); /**< pointer to platform release function */
47} hal_platform;
48
49/**
50 * @brief Initialise the HAL structure based on compile time config. This
51 * should be called before any other function in this API.
52 * @param[in,out] platform Pointer to a pre-allocated platform struct.
53 * @param[in,out] data_acq Pointer to a pre-allocated data acquisition module.
54 * @param[in,out] data_psn Pointer to a pre-allocated data presentation module.
55 * @param[in,out] timer Pointer to a pre-allocated timer module.
56 * @return 0 if successful, error code otherwise.
57 **/
58int hal_init(hal_platform *platform, data_acq_module *data_acq,
59 data_psn_module *data_psn, platform_timer *timer);
60
61
62/**
63 * @brief Initialise the HAL platform. This will go and initialise all the
64 * modules on the platform the application requires to run.
65 * @param[in] platform Pointer to a pre-allocated and initialised
66 * platform structure.
67 * @return 0 if successful, error code otherwise.
68 **/
69int hal_platform_init(hal_platform *platform);
70
71
72/**
73 * @brief Release the HAL platform. This should release resources acquired.
74 * @param[in] platform pointer to a pre-allocated and initialised
75 * platform structure.
76 **/
77void hal_platform_release(hal_platform *platform);
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* PLATFORM_HAL_H */