summaryrefslogtreecommitdiff
path: root/hw/bsp/board.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-04-17 20:06:13 +0700
committerhathach <[email protected]>2024-04-19 23:16:57 +0700
commit3442a87d5b52112a8bc4672322d488703e4ee23e (patch)
tree05cc69e08bfbda4d4114842304ab4fe67c7df466 /hw/bsp/board.c
parent96f7ca02bff64021b14ed84544df873a0d694a79 (diff)
- clang h743 build and run cdc_msc ok
- switch unit test back to gcc, since path to clang conflict on local setup (x86 and arm)
Diffstat (limited to 'hw/bsp/board.c')
-rw-r--r--hw/bsp/board.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/hw/bsp/board.c b/hw/bsp/board.c
index 23b4b6628..996ac9263 100644
--- a/hw/bsp/board.c
+++ b/hw/bsp/board.c
@@ -108,6 +108,25 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
// st->st_mode = S_IFCHR;
//}
+// Clang use picolibc
+#if defined(__clang__)
+static int cl_putc(char c, FILE *f) {
+ (void) f;
+ return sys_write(0, &c, 1);
+}
+
+static int cl_getc(FILE* f) {
+ (void) f;
+ char c;
+ return sys_read(0, &c, 1) > 0 ? c : -1;
+}
+
+static FILE __stdio = FDEV_SETUP_STREAM(cl_putc, cl_getc, NULL, _FDEV_SETUP_RW);
+FILE *const stdin = &__stdio;
+__strong_reference(stdin, stdout);
+__strong_reference(stdin, stderr);
+#endif
+
int board_getchar(void) {
char c;
return (sys_read(0, &c, 1) > 0) ? (int) c : (-1);