diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-09-23 15:27:41 -0400 |
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-09-23 15:27:41 -0400 |
| commit | 86130c8747a4af7ce93f4ac93d1c4d9c94c917eb (patch) | |
| tree | e289b5e59bb0143d9a744743978b2ae7360440e1 /project/Core | |
| parent | 73a76acef4aa14b042c9c56eef0fd19164afff42 (diff) | |
| download | 340-repo-Sowgro-86130c8747a4af7ce93f4ac93d1c4d9c94c917eb.tar.gz 340-repo-Sowgro-86130c8747a4af7ce93f4ac93d1c4d9c94c917eb.tar.bz2 340-repo-Sowgro-86130c8747a4af7ce93f4ac93d1c4d9c94c917eb.zip | |
Add activity 5
Diffstat (limited to '')
| -rw-r--r-- | project/Core/Inc/Activities/activity5.h | 13 | ||||
| -rw-r--r-- | project/Core/Inc/Homework/printf.h | 1 | ||||
| -rw-r--r-- | project/Core/Src/Activties/activity5.c | 24 | ||||
| -rw-r--r-- | project/Core/Src/Homework/printf.c | 5 | ||||
| -rw-r--r-- | project/Core/Src/main.c | 6 |
5 files changed, 47 insertions, 2 deletions
diff --git a/project/Core/Inc/Activities/activity5.h b/project/Core/Inc/Activities/activity5.h new file mode 100644 index 0000000..e74b3f0 --- /dev/null +++ b/project/Core/Inc/Activities/activity5.h @@ -0,0 +1,13 @@ +/* + * activity5.h + * + * Created on: Sep 23, 2025 + * Author: sowgro + */ + +#ifndef INC_ACTIVITIES_ACTIVITY5_H_ +#define INC_ACTIVITIES_ACTIVITY5_H_ + +void run2(); + +#endif /* INC_ACTIVITIES_ACTIVITY5_H_ */ diff --git a/project/Core/Inc/Homework/printf.h b/project/Core/Inc/Homework/printf.h index 4772dfd..a31119a 100644 --- a/project/Core/Inc/Homework/printf.h +++ b/project/Core/Inc/Homework/printf.h @@ -8,6 +8,7 @@ #ifndef INC_ACTIVITIES_PRINTF_H_ #define INC_ACTIVITIES_PRINTF_H_ +int putchar(int value); int printf(const char *format, ...); int puts(const char *string); diff --git a/project/Core/Src/Activties/activity5.c b/project/Core/Src/Activties/activity5.c new file mode 100644 index 0000000..9201f70 --- /dev/null +++ b/project/Core/Src/Activties/activity5.c @@ -0,0 +1,24 @@ +/* + * activity5.c + * + * Created on: Sep 23, 2025 + * Author: sowgro + */ + + +#include <UART.h> +#include "printf.h" + +void read_and_print_char() { + uint8_t ch = USART_Read(USART2); + printf("%c", ch); + if (ch == '\r') { + printf("\n"); + } +} + +void run2() { + for(;;) { + read_and_print_char(); + } +} diff --git a/project/Core/Src/Homework/printf.c b/project/Core/Src/Homework/printf.c index 60605f8..9384215 100644 --- a/project/Core/Src/Homework/printf.c +++ b/project/Core/Src/Homework/printf.c @@ -13,6 +13,11 @@ char buffer[120]; +int putchar(int value) { + USART_Write(USART2, (unsigned char *) &value, 1); + return 1; +} + int puts(const char *string) { int n = strlen(string); USART_Write(USART2, (unsigned char *) string, n); diff --git a/project/Core/Src/main.c b/project/Core/Src/main.c index 8d76d3a..ff819f2 100644 --- a/project/Core/Src/main.c +++ b/project/Core/Src/main.c @@ -8,6 +8,7 @@ #include "LED.h" #include "UART.h" #include "demo.h" +#include "activity5.h" #include "midi_header.h" #include <stdio.h> @@ -19,9 +20,10 @@ int main(void){ LED_Init(); UART2_Init(); - printf("Hello world \r\n"); +// printf("Hello world \r\n"); - run(); +// run(); + run2(); // application run function // run_demo() ; |
