Gabor Ambrus | 99c8ee4 | 2023-08-14 22:43:09 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <service/log/backend/log_backend.h> |
| 8 | #include <service/log/backend/uart/uart_adapter/uart_adapter.h> |
| 9 | #include <stddef.h> |
| 10 | |
| 11 | static log_status_t uart_puts(void *context, const char *str) |
| 12 | { |
| 13 | (void)context; |
| 14 | uart_hardware_puts(str); |
| 15 | |
| 16 | return LOG_STATUS_SUCCESS; |
| 17 | } |
| 18 | |
| 19 | struct log_backend *uart_backend_init(int uart_instance_num) |
| 20 | { |
| 21 | int status = 0; |
| 22 | static struct log_backend backend = {0}; |
| 23 | static const struct log_backend_interface interface = { uart_puts }; |
| 24 | |
| 25 | status = uart_adapter_init(uart_instance_num); |
| 26 | |
| 27 | if (status != 0) |
| 28 | return NULL; |
| 29 | |
| 30 | backend.context = NULL; |
| 31 | backend.interface = &interface; |
| 32 | |
| 33 | return &backend; |
| 34 | } |
| 35 | |
| 36 | void uart_backend_deinit(void) |
| 37 | { |
| 38 | uart_adapter_deinit(); |
| 39 | } |