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

Header file for the ADC task system. More...

#include <stdlib.h>
#include <stdio.h>
#include "stm32f4xx_hal.h"
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  ADCTask
 Structure that represents the ADC task state and configuration. More...

Typedefs

typedef struct ControllerTask ControllerTask
 Forward declaration for ControllerTask.
typedef struct PhotoresistorTask PhotoresistorTask
 Forward declaration for PhotoresistorTask.
typedef struct ADCTask ADCTask
 Forward declaration for ADCTask.
typedef void(* adc_fcn_t) (ADCTask *adc_task)
 Function pointer type for ADC state functions.

Functions

void adc_task_state_0_init (ADCTask *adc_task)
 Initializes the ADC task (state 0).
void adc_task_run (ADCTask *adc_task)
 Executes the current ADC task state.
void adc_task_state_1_read (ADCTask *adc_task)
 Reads and assigns values from the ADC DMA buffer (state 1).

Detailed Description

Header file for the ADC task system.

Author
Andrew Carr

Created on: Jun 5, 2025

Typedef Documentation

◆ adc_fcn_t

typedef void(* adc_fcn_t) (ADCTask *adc_task)

Function pointer type for ADC state functions.

Each state function must take a pointer to ADCTask as its argument.

◆ ControllerTask

typedef struct ControllerTask ControllerTask

Forward declaration for ControllerTask.

Forward declaration of ControllerTask structure.

◆ PhotoresistorTask

typedef struct PhotoresistorTask PhotoresistorTask

Forward declaration for PhotoresistorTask.

Forward declaration of PhotoresistorTask structure.

Function Documentation

◆ adc_task_run()

void adc_task_run ( ADCTask * adc_task)

Executes the current ADC task state.

Parameters
adc_taskPointer to the ADCTask instance.

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 (state 0).

Parameters
adc_taskPointer to the ADCTask instance.

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 and assigns values from the ADC DMA buffer (state 1).

Parameters
adc_taskPointer to the ADCTask instance.

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.