Works succesfully!

This commit is contained in:
2025-12-18 22:42:12 +03:00
parent 7ff25c2893
commit e45a7b89e9
9 changed files with 4277 additions and 4020 deletions

View File

@ -17,9 +17,9 @@
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "usb_device.h"
#include "usbd_cdc_if.h"
#include "main.h"
#include "usb_device.h"
#include "usbd_cdc_if.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
@ -60,16 +60,17 @@ static void MX_ADC1_Init(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* ADC_proc/ADC_proc_shadow/Sweep_state definitions */
volatile struct ADC_proc_typedef ADC_proc, ADC_proc_shadow;
volatile struct Sweep_state_typedef Sweep_state;
volatile uint32_t curr_step_start_N = 0;
/* ADC_proc/ADC_proc_shadow/Sweep_state definitions */
volatile struct ADC_proc_typedef ADC_proc, ADC_proc_shadow;
volatile struct Sweep_state_typedef Sweep_state;
volatile uint32_t curr_step_start_N = 0;
/* ADC1 circular DMA buffer definition */
uint16_t ADC1_buff_circular[ADC_BUFF_SIZE];
char ADC_msg[] = "Received ADC value: ??????????\r\n";
char ADC_msg[] = "curr_step ?????? ??????????\r\n";
#define ADC_msg_len 32
#define ADC_msg_val_pos 20
#define ADC_msg_step_pos 12
/* USER CODE END 0 */
/**
@ -118,13 +119,16 @@ int main(void)
ADC_proc.sum = 0;
ADC_proc.avg = 0;
uint32_t curr_points_N_max = 100;
uint32_t curr_points_N =0;
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
//HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
//HAL_Delay(100);
if (ADC_proc_shadow.status == 2) {
@ -144,7 +148,24 @@ int main(void)
ADC_msg[ADC_msg_val_pos + 7] = (ADC_proc_shadow.avg / 100) % 10 + '0';
ADC_msg[ADC_msg_val_pos + 8] = (ADC_proc_shadow.avg / 10) % 10 + '0';
ADC_msg[ADC_msg_val_pos + 9] = (ADC_proc_shadow.avg / 1) % 10 + '0';
ADC_msg[ADC_msg_step_pos + 0] = (Sweep_state.curr_step_N / 100000) % 10 + '0';
ADC_msg[ADC_msg_step_pos + 1] = (Sweep_state.curr_step_N / 10000) % 10 + '0';
ADC_msg[ADC_msg_step_pos + 2] = (Sweep_state.curr_step_N / 1000) % 10 + '0';
ADC_msg[ADC_msg_step_pos + 3] = (Sweep_state.curr_step_N / 100) % 10 + '0';
ADC_msg[ADC_msg_step_pos + 4] = (Sweep_state.curr_step_N / 10) % 10 + '0';
ADC_msg[ADC_msg_step_pos + 5] = (Sweep_state.curr_step_N / 1) % 10 + '0';
CDC_Transmit_FS((uint8_t *)ADC_msg, ADC_msg_len);
//HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
if (Sweep_state.curr_step_N > 1000){
Sweep_state.curr_step_N = 0;
HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
HAL_DelayUS(10);
CDC_Transmit_FS((uint8_t *)"Sweep_start\n\r", 14);
}
}
//CDC_Transmit_FS((uint8_t *)"Hello from STM32!\r\n", 19);