1 /* 2 * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved. 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 #ifndef _CONSOLE_H_ 16 #define _CONSOLE_H_ 17 18 #include "arch.h" 19 #include "dbg.h" 20 #include <stdbool.h> 21 22 #define console_putf(args...) dbg(args) 23 #define CONSOLE_CRITICAL_START() GLOBAL_INT_DISABLE() 24 #define CONSOLE_CRITICAL_END() GLOBAL_INT_RESTORE() 25 26 #define CONSOLE_GLOBAL_DEBUG_MODE 1 27 28 typedef enum { 29 ERR_NONE = 0, 30 ERR_UNKNOWN_CMD = -1, 31 ERR_WRONG_ARGS = -2, 32 ERR_CMD_ABORT = -3, 33 ERR_CMD_FAIL = -4, 34 } CONSOLE_ERR_CODE_T; 35 36 #ifdef CFG_RTOS 37 /// Pointer to callback function 38 typedef void (*rtos_notify_cb_t)(bool isr); 39 #endif 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 extern volatile bool cmd_exe_in_irq; 46 47 void console_init(void); 48 void console_putc(char c); 49 void console_puts(const char *s); 50 void console_schedule(void); 51 int console_cmd_add(const char *name, const char *usage, int maxargs, int (*func)(int, char *[])); 52 unsigned int console_cmd_strtoul(const char *cp, char **endp, unsigned int base); 53 unsigned int console_buf_empty(void); 54 #ifdef CFG_RTOS 55 void console_ntf_register(rtos_notify_cb_t notify_cb); 56 #endif /* CFG_RTOS */ 57 #if CONSOLE_GLOBAL_DEBUG_MODE 58 void console_global_dbgmode_enable(void); 59 #endif /* CONSOLE_GLOBAL_DEBUG_MODE */ 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 66 #endif /* _CONSOLE_H_ */ 67