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