/* * Copyright (C) 2017-2019 Alibaba Group Holding Limited */ /****************************************************************************** * @file minilibc_port.c * @brief minilibc port * @version V1.0 * @date 26. Dec 2017 ******************************************************************************/ #include #include #ifndef CONFIG_KERNEL_NONE #include #endif #include usart_handle_t console_handle = NULL; __attribute__((weak)) int write(int __fd, __const void *__buf, int __n) { return 0; } int fputc(int ch, FILE *stream) { (void)stream; if (console_handle == NULL) { return -1; } if (ch == '\n') { csi_usart_putchar(console_handle, '\r'); } csi_usart_putchar(console_handle, ch); return 0; } int fgetc(FILE *stream) { uint8_t ch; (void)stream; if (console_handle == NULL) { return -1; } csi_usart_getchar(console_handle, &ch); return ch; } int os_critical_enter(unsigned int *lock) { (void)lock; #ifndef CONFIG_KERNEL_NONE csi_kernel_sched_suspend(); #endif return 0; } int os_critical_exit(unsigned int *lock) { (void)lock; #ifndef CONFIG_KERNEL_NONE csi_kernel_sched_resume(0); #endif return 0; }