summaryrefslogtreecommitdiff
path: root/project/Core
diff options
context:
space:
mode:
Diffstat (limited to 'project/Core')
-rw-r--r--project/Core/Inc/Homework/printf.h13
-rw-r--r--project/Core/Src/Homework/printf.c21
-rw-r--r--project/Core/Src/main.c8
3 files changed, 38 insertions, 4 deletions
diff --git a/project/Core/Inc/Homework/printf.h b/project/Core/Inc/Homework/printf.h
new file mode 100644
index 0000000..48952dc
--- /dev/null
+++ b/project/Core/Inc/Homework/printf.h
@@ -0,0 +1,13 @@
+/*
+ * printf.h
+ *
+ * Created on: Sep 5, 2025
+ * Author: sowgro
+ */
+
+#ifndef INC_ACTIVITIES_PRINTF_H_
+#define INC_ACTIVITIES_PRINTF_H_
+
+int printf(const char *format, ...);
+
+#endif /* INC_ACTIVITIES_PRINTF_H_ */
diff --git a/project/Core/Src/Homework/printf.c b/project/Core/Src/Homework/printf.c
new file mode 100644
index 0000000..56216ad
--- /dev/null
+++ b/project/Core/Src/Homework/printf.c
@@ -0,0 +1,21 @@
+/*
+ * printf.c
+ *
+ * Created on: Sep 5, 2025
+ * Author: sowgro
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include "UART.h"
+#include "printf.h"
+
+char buffer[80];
+int printf(const char *format, ...) {
+ va_list args;
+ va_start(args, format);
+ int n = vsprintf(buffer, format, args);
+ va_end(args);
+ USART_Write(USART2, (unsigned char *) buffer, n);
+ return n;
+}
diff --git a/project/Core/Src/main.c b/project/Core/Src/main.c
index c2147cd..f8709f3 100644
--- a/project/Core/Src/main.c
+++ b/project/Core/Src/main.c
@@ -18,11 +18,11 @@ int main(void){
LED_Init();
UART2_Init();
- char buffer[64];
- int n = sprintf(buffer, "Hello\n\r");
- USART_Write(USART2, (unsigned char *) buffer, n);
+ int a = 1;
+ int b = 2;
+ printf("Hello %i %i \n\r", a, b);
// application run function
-// run_demo() ;
+ // run_demo() ;
}