blob: 1e40b029350cca183d03b21d5b0a8171cd3c817f [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#include "data_acq.h"
18
19#include "bsp.h"
20
21#include <assert.h>
22#include <stdlib.h>
23#include <string.h>
24
25/**
26 * @brief Get the user input from USART.
27 * @param[out] user_input String read from the UART block.
28 * @param[in] size String read length.
29 * @return 0 if successful, error code otherwise.
30 **/
31static int get_uart_user_input(char* user_input, int size)
32{
33 if (true != GetLine(user_input, size - 1)) {
34 printf_err("invalid input\n");
35 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}