blob: ec6c725dff9149dddbaf29d0490b250b1aa4e7d2 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
Isabella Gottardiee4920b2022-02-25 14:29:32 +00002 * Copyright (c) 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#include "data_acq.h"
18
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000019#include "log_macros.h"
Isabella Gottardiee4920b2022-02-25 14:29:32 +000020#include "platform_drivers.h"
alexander3c798932021-03-26 21:42:19 +000021
22#include <assert.h>
23#include <stdlib.h>
24#include <string.h>
25
26/**
27 * @brief Get the user input from USART.
28 * @param[out] user_input String read from the UART block.
29 * @param[in] size String read length.
30 * @return 0 if successful, error code otherwise.
31 **/
32static int get_uart_user_input(char* user_input, int size)
33{
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000034 if (1 != GetLine(user_input, size - 1)) {
alexander3c798932021-03-26 21:42:19 +000035 return 1;
36 }
37 return 0;
38}
39
40int data_acq_channel_init(data_acq_module* module)
41{
42 assert(module);
43
44 /* UART should have been initialised with low level initialisation
45 * routines. */
46 module->system_init = NULL;
47
48 strncpy(module->system_name, "UART", sizeof(module->system_name));
49 module->get_input = get_uart_user_input;
50 module->inited = 1;
51
52 return !(module->inited);
53}
54
55int data_acq_channel_release(data_acq_module* module)
56{
57 assert(module);
58 module->inited = 0;
59 module->get_input = NULL;
60 return 0;
61}