blob: 25ea1e20d93b49916992e5c0dc52ce6f28c82213 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +00002 * Copyright (c) 2021-2022 Arm Limited. All rights reserved.
alexander3c798932021-03-26 21:42:19 +00003 * 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 */
alexander3c798932021-03-26 21:42:19 +000026
27#ifdef __cplusplus
28extern "C" {
29#endif
30
Kshitij Sisodia68fdd112022-04-06 13:03:20 +010031#include "platform_drivers.h" /* Platform drivers */
32#include "timer.h" /* Timer/profiler API */
33#include "hal_lcd.h" /* LCD functions */
alexander3c798932021-03-26 21:42:19 +000034
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010035#include <inttypes.h>
Kshitij Sisodia68fdd112022-04-06 13:03:20 +010036#include <stdbool.h>
Kshitij Sisodiaf9c19ea2021-05-07 16:08:14 +010037
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 */
Kshitij Sisodia68fdd112022-04-06 13:03:20 +010042 platform_timer* timer; /**< timer */
alexander3c798932021-03-26 21:42:19 +000043 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.
alexander3c798932021-03-26 21:42:19 +000051 * @param[in,out] timer Pointer to a pre-allocated timer module.
52 * @return 0 if successful, error code otherwise.
53 **/
Kshitij Sisodia68fdd112022-04-06 13:03:20 +010054int hal_init(hal_platform* platform, platform_timer* timer);
alexander3c798932021-03-26 21:42:19 +000055
56
57/**
58 * @brief Initialise the HAL platform. This will go and initialise all the
59 * modules on the platform the application requires to run.
60 * @param[in] platform Pointer to a pre-allocated and initialised
61 * platform structure.
62 * @return 0 if successful, error code otherwise.
63 **/
Kshitij Sisodia68fdd112022-04-06 13:03:20 +010064int hal_platform_init(hal_platform* platform);
alexander3c798932021-03-26 21:42:19 +000065
66
67/**
68 * @brief Release the HAL platform. This should release resources acquired.
69 * @param[in] platform pointer to a pre-allocated and initialised
70 * platform structure.
71 **/
Kshitij Sisodia68fdd112022-04-06 13:03:20 +010072void hal_platform_release(hal_platform* platform);
73
74/**
75 * @brief Gets user input from the stdin interface.
76 * @param[out] user_input Pointer to a buffer where the input will be stored.
77 * @param[in] size Buffer size in bytes.
78 * @return True if successful, false otherwise.
79 */
80bool hal_get_user_input(char* user_input, int size);
alexander3c798932021-03-26 21:42:19 +000081
82#ifdef __cplusplus
83}
84#endif
85
86#endif /* PLATFORM_HAL_H */