Zap'Em Blast'Em Robots
robots that play laser tag!
Loading...
Searching...
No Matches
adc_task.c File Reference

ADC task driver for managing DMA-based ADC value acquisition and assignment. More...

#include "adc_task.h"
#include "stm32f4xx_hal_tim.h"
#include <stdio.h>
#include "controller_task.h"
#include "photoresistor_task.h"

Functions

void adc_task_run (ADCTask *adc_task)
 Executes the current state of the ADC task.
void adc_task_state_0_init (ADCTask *adc_task)
 Initializes the ADC task.
void adc_task_state_1_read (ADCTask *adc_task)
 Reads ADC values from DMA buffer and assigns them to respective photo resistors and controllers.

Detailed Description

ADC task driver for managing DMA-based ADC value acquisition and assignment.

Author
Andrew Carr

Created on: Jun 5, 2025

Function Documentation

◆ adc_task_run()

void adc_task_run ( ADCTask * adc_task)

Executes the current state of the ADC task.

Executes the current ADC task state.

This function checks the validity of the current state, then calls the corresponding state handler from the state's function pointer list.

Parameters
adc_taskPointer to the ADCTask structure containing state and hardware info.

◆ adc_task_state_0_init()

void adc_task_state_0_init ( ADCTask * adc_task)

Initializes the ADC task.

Initializes the ADC task (state 0).

Sets the task's state to 1 and starts the ADC with DMA to fill the dma_buffer.

Parameters
adc_taskPointer to the ADCTask structure.

◆ adc_task_state_1_read()

void adc_task_state_1_read ( ADCTask * adc_task)

Reads ADC values from DMA buffer and assigns them to respective photo resistors and controllers.

Reads and assigns values from the ADC DMA buffer (state 1).

This function maps each DMA buffer value to its corresponding sensor's adc_val.

Parameters
adc_taskPointer to the ADCTask structure.