move adc sampling to DMA TC interrupt

calib-gui
Ondřej Hruška 2 years ago
parent 6eb18ac72e
commit bff7f6e916
  1. 10
      Core/Src/app_main.c
  2. 3
      Core/Src/app_temp.c
  3. 7
      Core/Src/stm32f1xx_it.c

@ -92,6 +92,14 @@ void app_task_main(void *argument)
oled_init();
fb_clear();
// while(1) {
// LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
// vTaskDelay(pdMS_TO_TICKS(250));
// LL_IWDG_ReloadCounter(IWDG);
// }
/* Infinite loop */
bool old_pushed = app_knob_pushed();
@ -141,8 +149,6 @@ void app_task_main(void *argument)
uint32_t now = osKernelGetTickCount();
if (any_change || (now - last_redraw > pdMS_TO_TICKS(500))) {
PUTS("Cycle\r\n");
PRINTF("test printf\r\n");
last_redraw = now;
redraw_display();
any_change = false;

@ -153,7 +153,7 @@ void app_analog_init()
LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_1, 4);
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_1);
LL_ADC_EnableIT_EOS(ADC_TEMP);
LL_DMA_EnableIT_TC(DMA1, LL_DMA_CHANNEL_1);
LL_ADC_REG_StartConversionExtTrig(ADC_TEMP, LL_ADC_REG_TRIG_EXT_RISING);
LL_ADC_REG_StartConversionSWStart(ADC_TEMP);
@ -241,6 +241,7 @@ float app_temp_read_soc()
void app_temp_adc_eos()
{
PUTCHAR('a');
// notify
memcpy((void *) &s_analog.adc_averagebuf[s_analog.averagebuf_ptr * 4], (const void *) adc_values, 4 * sizeof(uint16_t));
s_analog.averagebuf_ptr = (s_analog.averagebuf_ptr + 1) % AVERAGEBUF_DEPTH;

@ -194,6 +194,11 @@ void DMA1_Channel1_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
if (LL_DMA_IsActiveFlag_TC1(DMA1)) {
app_temp_adc_eos();
LL_DMA_ClearFlag_TC1(DMA1);
}
/* USER CODE END DMA1_Channel1_IRQn 0 */
/* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
@ -208,7 +213,7 @@ void ADC1_2_IRQHandler(void)
{
/* USER CODE BEGIN ADC1_2_IRQn 0 */
app_temp_adc_eos();
// app_temp_adc_eos();
// if (LL_ADC_IsActiveFlag_EOS(ADC_TEMP)) {
// LL_ADC_ClearFlag_EOS(ADC_TEMP);

Loading…
Cancel
Save