alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 1 | /* |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 2 | * Copyright (c) 2021-2022 Arm Limited. All rights reserved. |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 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 | */ |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 26 | |
| 27 | #ifdef __cplusplus |
| 28 | extern "C" { |
| 29 | #endif |
| 30 | |
Kshitij Sisodia | 68fdd11 | 2022-04-06 13:03:20 +0100 | [diff] [blame^] | 31 | #include "platform_drivers.h" /* Platform drivers */ |
| 32 | #include "timer.h" /* Timer/profiler API */ |
| 33 | #include "hal_lcd.h" /* LCD functions */ |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 34 | |
Kshitij Sisodia | f9c19ea | 2021-05-07 16:08:14 +0100 | [diff] [blame] | 35 | #include <inttypes.h> |
Kshitij Sisodia | 68fdd11 | 2022-04-06 13:03:20 +0100 | [diff] [blame^] | 36 | #include <stdbool.h> |
Kshitij Sisodia | f9c19ea | 2021-05-07 16:08:14 +0100 | [diff] [blame] | 37 | |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 38 | /* Structure to define a platform context to be used by the application */ |
| 39 | typedef struct hal_platform_context { |
| 40 | int inited; /**< initialised */ |
Kshitij Sisodia | f9c19ea | 2021-05-07 16:08:14 +0100 | [diff] [blame] | 41 | char plat_name[64]; /**< name of this platform */ |
Kshitij Sisodia | 68fdd11 | 2022-04-06 13:03:20 +0100 | [diff] [blame^] | 42 | platform_timer* timer; /**< timer */ |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 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. |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 51 | * @param[in,out] timer Pointer to a pre-allocated timer module. |
| 52 | * @return 0 if successful, error code otherwise. |
| 53 | **/ |
Kshitij Sisodia | 68fdd11 | 2022-04-06 13:03:20 +0100 | [diff] [blame^] | 54 | int hal_init(hal_platform* platform, platform_timer* timer); |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 55 | |
| 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 Sisodia | 68fdd11 | 2022-04-06 13:03:20 +0100 | [diff] [blame^] | 64 | int hal_platform_init(hal_platform* platform); |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 65 | |
| 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 Sisodia | 68fdd11 | 2022-04-06 13:03:20 +0100 | [diff] [blame^] | 72 | void 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 | */ |
| 80 | bool hal_get_user_input(char* user_input, int size); |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 81 | |
| 82 | #ifdef __cplusplus |
| 83 | } |
| 84 | #endif |
| 85 | |
| 86 | #endif /* PLATFORM_HAL_H */ |