implemented sweep and current steps processing. But not compiles
This commit is contained in:
@ -59,8 +59,9 @@ static void MX_ADC1_Init(void);
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
/* adc_process definition is provided here; structure is declared in main.h */
|
||||
struct ADC_proc adc_process;
|
||||
/* ADC_proc_shadow definition is provided here; structure is declared in main.h */
|
||||
struct ADC_proc_typedef ADC_proc, ADC_proc_shadow;
|
||||
struct Sweep_state_typedef Sweep_state;
|
||||
|
||||
/* ADC1 circular DMA buffer definition */
|
||||
uint16_t ADC1_buff_circular[ADC_BUFF_SIZE];
|
||||
@ -104,10 +105,16 @@ int main(void)
|
||||
/* USER CODE BEGIN 2 */
|
||||
HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_SET);
|
||||
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)ADC1_buff_circular, ADC_BUFF_SIZE);
|
||||
adc_process.status = 0; // ADC started
|
||||
adc_process.N = 0;
|
||||
adc_process.sum = 0;
|
||||
adc_process.avg = 0;
|
||||
|
||||
ADC_proc_shadow.status = 0; // ADC started
|
||||
ADC_proc_shadow.N = 0;
|
||||
ADC_proc_shadow.sum = 0;
|
||||
ADC_proc_shadow.avg = 0;
|
||||
|
||||
ADC_proc.status = 0; // ADC started
|
||||
ADC_proc.N = 0;
|
||||
ADC_proc.sum = 0;
|
||||
ADC_proc.avg = 0;
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
@ -118,23 +125,23 @@ int main(void)
|
||||
HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
|
||||
//HAL_Delay(100);
|
||||
|
||||
if (adc_process.status == 2) {
|
||||
adc_process.avg = adc_process.sum / adc_process.N;
|
||||
adc_process.status = 1; // reset for next accumulation
|
||||
adc_process.sum = 0;
|
||||
adc_process.N = 0;
|
||||
if (ADC_proc_shadow.status == 2) {
|
||||
ADC_proc_shadow.avg = ADC_proc_shadow.sum / ADC_proc_shadow.N;
|
||||
ADC_proc_shadow.status = 1; // reset for next accumulation
|
||||
ADC_proc_shadow.sum = 0;
|
||||
ADC_proc_shadow.N = 0;
|
||||
|
||||
|
||||
ADC_msg[ADC_msg_val_pos + 0] = (adc_process.avg / 10000000000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 1] = (adc_process.avg / 1000000000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 2] = (adc_process.avg / 10000000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 3] = (adc_process.avg / 1000000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 4] = (adc_process.avg / 100000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 5] = (adc_process.avg / 10000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 6] = (adc_process.avg / 1000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 7] = (adc_process.avg / 100) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 8] = (adc_process.avg / 10) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 9] = (adc_process.avg / 1) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 0] = (ADC_proc_shadow.avg / 10000000000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 1] = (ADC_proc_shadow.avg / 1000000000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 2] = (ADC_proc_shadow.avg / 10000000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 3] = (ADC_proc_shadow.avg / 1000000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 4] = (ADC_proc_shadow.avg / 100000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 5] = (ADC_proc_shadow.avg / 10000) % 10 + '0';
|
||||
ADC_msg[ADC_msg_val_pos + 6] = (ADC_proc_shadow.avg / 1000) % 10 + '0';
|
||||
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';
|
||||
CDC_Transmit_FS((uint8_t *)ADC_msg, ADC_msg_len);
|
||||
|
||||
}
|
||||
@ -285,6 +292,18 @@ static void MX_GPIO_Init(void)
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin : CURR_STEP_START_TRG_Pin */
|
||||
GPIO_InitStruct.Pin = CURR_STEP_START_TRG_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
HAL_GPIO_Init(CURR_STEP_START_TRG_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*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;
|
||||
HAL_GPIO_Init(SWEEP_CYCLE_START_TRG_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PF11 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
||||
@ -298,6 +317,13 @@ static void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* EXTI interrupt init*/
|
||||
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
|
||||
|
||||
HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI3_IRQn);
|
||||
|
||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||
|
||||
/* USER CODE END MX_GPIO_Init_2 */
|
||||
|
||||
Reference in New Issue
Block a user