1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15
16 #include "tensorflow/lite/micro/debug_log.h"
17
18 #include <stm32f4xx_hal.h>
19 #include <stm32f4xx_hal_uart.h>
20
21 #include <cstdio>
22
23 extern UART_HandleTypeDef DEBUG_UART_HANDLE;
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #ifdef __GNUC__
__io_putchar(int ch)30 int __io_putchar(int ch) {
31 HAL_UART_Transmit(&DEBUG_UART_HANDLE, (uint8_t*)&ch, 1, HAL_MAX_DELAY);
32
33 return ch;
34 }
35 #else
36 int fputc(int ch, FILE* f) {
37 HAL_UART_Transmit(&DEBUG_UART_HANDLE, (uint8_t*)&ch, 1, HAL_MAX_DELAY);
38
39 return ch;
40 }
41 #endif /* __GNUC__ */
42
DebugLog(const char * s)43 void DebugLog(const char* s) { fprintf(stderr, "%s", s); }
44
45 #ifdef __cplusplus
46 }
47 #endif
48