somehow works with real radar. USB is not fast enough: some lines are missing
This commit is contained in:
@ -60,9 +60,9 @@ void Error_Handler(void);
|
||||
#define CURR_STEP_START_TRG_Pin GPIO_PIN_0
|
||||
#define CURR_STEP_START_TRG_GPIO_Port GPIOC
|
||||
#define CURR_STEP_START_TRG_EXTI_IRQn EXTI0_IRQn
|
||||
#define SWEEP_CYCLE_START_TRG_Pin GPIO_PIN_1
|
||||
#define SWEEP_CYCLE_START_TRG_Pin GPIO_PIN_3
|
||||
#define SWEEP_CYCLE_START_TRG_GPIO_Port GPIOC
|
||||
#define SWEEP_CYCLE_START_TRG_EXTI_IRQn EXTI1_IRQn
|
||||
#define SWEEP_CYCLE_START_TRG_EXTI_IRQn EXTI3_IRQn
|
||||
#define LED_RED_Pin GPIO_PIN_14
|
||||
#define LED_RED_GPIO_Port GPIOB
|
||||
#define LED_BLUE_Pin GPIO_PIN_7
|
||||
@ -76,28 +76,29 @@ void Error_Handler(void);
|
||||
#define ADC_BUFF_SIZE 100
|
||||
#endif
|
||||
|
||||
/* Structure describing simple accumulation state for ADC processing */
|
||||
struct ADC_proc_typedef {
|
||||
uint8_t status; /* 0 - stopped, 1 - collecting, 2 - filled */
|
||||
uint32_t sum;
|
||||
uint32_t avg;
|
||||
uint32_t N;
|
||||
};
|
||||
|
||||
/* Sweep state shared between ISR and main */
|
||||
struct Sweep_state_typedef {
|
||||
uint32_t curr_step_N;
|
||||
uint8_t curr_step_started_flag; //0 -- not started or waiting for; 1 -- first 1/2 DMA buff; 2 -- second 1/2 DMA buff
|
||||
uint32_t curr_step_start_DMA_N;
|
||||
|
||||
};
|
||||
|
||||
/* Externs provided by main.c */
|
||||
extern volatile struct ADC_proc_typedef ADC_proc;
|
||||
extern volatile struct ADC_proc_typedef ADC_proc_shadow;
|
||||
extern volatile struct Sweep_state_typedef Sweep_state;
|
||||
extern volatile uint32_t curr_step_start_N;
|
||||
extern uint16_t ADC1_buff_circular[ADC_BUFF_SIZE];
|
||||
/* Structure describing simple accumulation state for ADC processing */
|
||||
struct ADC_proc_typedef {
|
||||
uint8_t status; /* 0 - stopped, 1 - collecting, 2 - filled */
|
||||
uint32_t sum;
|
||||
uint32_t avg;
|
||||
uint32_t N;
|
||||
};
|
||||
|
||||
/* Sweep state shared between ISR and main */
|
||||
struct Sweep_state_typedef {
|
||||
uint32_t curr_step_N;
|
||||
uint8_t curr_step_started_flag; //0 -- not started or waiting for; 1 -- first 1/2 DMA buff; 2 -- second 1/2 DMA buff
|
||||
uint32_t curr_step_start_DMA_N;
|
||||
uint8_t sweep_cycle_started_flag; // 0 -- not started; 1 -- started
|
||||
|
||||
};
|
||||
|
||||
/* Externs provided by main.c */
|
||||
extern volatile struct ADC_proc_typedef ADC_proc;
|
||||
extern volatile struct ADC_proc_typedef ADC_proc_shadow;
|
||||
extern volatile struct Sweep_state_typedef Sweep_state;
|
||||
extern volatile uint32_t curr_step_start_N;
|
||||
extern uint16_t ADC1_buff_circular[ADC_BUFF_SIZE];
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "usb_device.h"
|
||||
#include "usbd_cdc_if.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
@ -67,10 +66,12 @@ volatile uint32_t curr_step_start_N = 0;
|
||||
|
||||
/* ADC1 circular DMA buffer definition */
|
||||
uint16_t ADC1_buff_circular[ADC_BUFF_SIZE];
|
||||
char ADC_msg[] = "curr_step ?????? ??????????\r\n";
|
||||
#define ADC_msg_len 32
|
||||
#define ADC_msg_val_pos 20
|
||||
#define ADC_msg_step_pos 12
|
||||
//char ADC_msg[] = "curr_step ?????? ??????????\r\nSweep_start\n\r";
|
||||
char ADC_msg[] = "stp ?????? ??????????\r\nSweep_start\n\r";
|
||||
#define ADC_msg_len 24
|
||||
#define ADC_msg_len_Sweep_start 37
|
||||
#define ADC_msg_val_pos 12
|
||||
#define ADC_msg_step_pos 4
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@ -157,14 +158,21 @@ int main(void)
|
||||
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){
|
||||
|
||||
if (Sweep_state.curr_step_N > 10000){
|
||||
Sweep_state.curr_step_N = 0;
|
||||
Sweep_state.sweep_cycle_started_flag = 1;
|
||||
}
|
||||
if (Sweep_state.sweep_cycle_started_flag == 1){
|
||||
Sweep_state.sweep_cycle_started_flag = 0; // reset sweep cycle flag
|
||||
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 *)ADC_msg, ADC_msg_len_Sweep_start);
|
||||
|
||||
}else{
|
||||
CDC_Transmit_FS((uint8_t *)ADC_msg, ADC_msg_len);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -324,7 +332,7 @@ static void MX_GPIO_Init(void)
|
||||
/*Configure GPIO pin : SWEEP_CYCLE_START_TRG_Pin */
|
||||
GPIO_InitStruct.Pin = SWEEP_CYCLE_START_TRG_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(SWEEP_CYCLE_START_TRG_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PF11 */
|
||||
|
||||
@ -225,7 +225,8 @@ void EXTI0_IRQHandler(void)
|
||||
void EXTI3_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN EXTI3_IRQn 0 */
|
||||
|
||||
Sweep_state.sweep_cycle_started_flag = 1; //sweep cycle started
|
||||
Sweep_state.curr_step_N = 0;
|
||||
/* USER CODE END EXTI3_IRQn 0 */
|
||||
HAL_GPIO_EXTI_IRQHandler(SWEEP_CYCLE_START_TRG_Pin);
|
||||
/* USER CODE BEGIN EXTI3_IRQn 1 */
|
||||
|
||||
Reference in New Issue
Block a user