From 94189c8d7c13cc27b3d8dd11f9003cd9587da54d Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 9 Sep 2025 15:16:07 -0400 Subject: In class work --- project/Core/Inc/Homework/printf.h | 1 + project/Core/Src/Activties/activity1.txt | 25 +++++++++++++++++++++++++ project/Core/Src/Homework/printf.c | 11 ++++++++++- project/Core/Src/main.c | 4 +--- project/project Debug.launch | 1 + 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 project/Core/Src/Activties/activity1.txt diff --git a/project/Core/Inc/Homework/printf.h b/project/Core/Inc/Homework/printf.h index 48952dc..4772dfd 100644 --- a/project/Core/Inc/Homework/printf.h +++ b/project/Core/Inc/Homework/printf.h @@ -9,5 +9,6 @@ #define INC_ACTIVITIES_PRINTF_H_ int printf(const char *format, ...); +int puts(const char *string); #endif /* INC_ACTIVITIES_PRINTF_H_ */ diff --git a/project/Core/Src/Activties/activity1.txt b/project/Core/Src/Activties/activity1.txt new file mode 100644 index 0000000..8a46d68 --- /dev/null +++ b/project/Core/Src/Activties/activity1.txt @@ -0,0 +1,25 @@ +73 - 64 = 9 +9 - 8 = 1 + +0100 1001 + +2^2 + 2^3 + 2^0 +4 9 +0x49 + + +-5 + +0000 0000 +0000 0101 +1111 1011 + +8 + 4 + 2 + 1 = F +8 + 2 + 1 = B + +0xFB + +0b 1101 0110 +2 + 4 + 16 + 64 + 128 = + +0xD6 \ No newline at end of file diff --git a/project/Core/Src/Homework/printf.c b/project/Core/Src/Homework/printf.c index 56216ad..60605f8 100644 --- a/project/Core/Src/Homework/printf.c +++ b/project/Core/Src/Homework/printf.c @@ -7,10 +7,19 @@ #include #include +#include #include "UART.h" #include "printf.h" -char buffer[80]; +char buffer[120]; + +int puts(const char *string) { + int n = strlen(string); + USART_Write(USART2, (unsigned char *) string, n); + USART_Write(USART2, (unsigned char *) "\n", 1); + return n + 1; +} + int printf(const char *format, ...) { va_list args; va_start(args, format); diff --git a/project/Core/Src/main.c b/project/Core/Src/main.c index f8709f3..1b6d449 100644 --- a/project/Core/Src/main.c +++ b/project/Core/Src/main.c @@ -18,9 +18,7 @@ int main(void){ LED_Init(); UART2_Init(); - int a = 1; - int b = 2; - printf("Hello %i %i \n\r", a, b); + printf("Hello world \r\n"); // application run function // run_demo() ; diff --git a/project/project Debug.launch b/project/project Debug.launch index b736426..9240703 100644 --- a/project/project Debug.launch +++ b/project/project Debug.launch @@ -81,5 +81,6 @@ + -- cgit v1.2.3