diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-08-31 13:25:35 -0400 |
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-08-31 13:25:35 -0400 |
| commit | 0ff718e7cd7159c30636aa323a666ac1af684f63 (patch) | |
| tree | 247e13a76a15d3f826ba949a5a4d82b79a35e652 /project/Core/Src/demo.c | |
| parent | 0f2ea7deaf0cba2f0ca07f6611c5a9e87d531f5b (diff) | |
| download | 340-repo-Sowgro-0ff718e7cd7159c30636aa323a666ac1af684f63.tar.gz 340-repo-Sowgro-0ff718e7cd7159c30636aa323a666ac1af684f63.tar.bz2 340-repo-Sowgro-0ff718e7cd7159c30636aa323a666ac1af684f63.zip | |
Setup project
Diffstat (limited to 'project/Core/Src/demo.c')
| -rw-r--r-- | project/Core/Src/demo.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/project/Core/Src/demo.c b/project/Core/Src/demo.c new file mode 100644 index 0000000..d34b7e3 --- /dev/null +++ b/project/Core/Src/demo.c @@ -0,0 +1,55 @@ +/* + * demo.c + * + * Created on: Feb 14, 2021 + * Author: larry kiser + * Updated on: Sept 6, 2021 + * Author: Mitesh Parikh + */ + +#include <stdio.h> +#include <string.h> + +// Custom Include files +#include "LED.h" +#include "UART.h" +#include "demo.h" +#include "stm32l4xx.h" + + +// This function is to create a delay by consuming CPU cycle on counter +static void delay_loop( int value ) +{ + // spin loop consuming CPU to spend time. + for (int i = 0; i < value; i++) + ; +} + +// This function is to print counter on UART port and toggle LED +static void demo_of_UART_print(int counter){ + int n ; + uint8_t buffer[BUFFER_SIZE]; + + n = sprintf((char *)buffer, "counter = %d\r\n", counter); + USART_Write(USART2, buffer, n); + + delay_loop( 8000000 ) ; // comment this out when you are ready to test delay_systick + // delay_systick() ; // enable this when you are ready to test + + // Toggle LED + LED_Toggle(); +} + +void run_demo(){ + + int counter = 0; + + // Run a loop to print counter value on UART port + while (1) + { + //demo_of_printf_scanf(); + demo_of_UART_print(counter); + counter++; + } +} + |
