Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
AnalogSensor.h
Go to the documentation of this file.
1#ifndef RENSSELAERMOTORSPORT_ANALOGSENSOR_H
2#define RENSSELAERMOTORSPORT_ANALOGSENSOR_H
3
4#ifndef TEST_MODE
5// STM32 HAL includes
6#include "stm32f7xx.h"
7#include "stm32f7xx_hal.h"
8#include "stm32f7xx_hal_adc.h"
9#include "stm32f7xx_hal_dma.h"
10#include "stm32f7xx_hal_uart.h"
11#endif
12
13// Standard C includes
14#include <stdio.h>
15#include <string.h>
16#include <stdint.h>
17
18// User includes
19#include "Sensor.h"
20
21// Structures
22typedef struct {
25 void* child; // Pointer to the child struct
27
28// Function declarations
29
41void initAnalogSensor(AnalogSensor* analogSensor, const char* name, int hz, int channel, void* child);
42
53void ProcessADCData(uint32_t* adc1_buffer, uint32_t* adc2_buffer, uint32_t* adc3_buffer);
54
65
66#ifndef TEST_MODE
67// External variable declarations
68extern ADC_HandleTypeDef hadc1, hadc2, hadc3;
69extern DMA_HandleTypeDef hdma_adc1, hdma_adc2, hdma_adc3;
70#endif
71
72// ADC buffers
73extern uint32_t adc1_buffer[7];
74extern uint32_t adc2_buffer[7];
75extern uint32_t adc3_buffer[8];
76
77#endif // RENSSELAERMOTORSPORT_ANALOGSENSOR_H
78
DMA_HandleTypeDef hdma_adc1
Definition: main.c:63
ADC_HandleTypeDef hadc1
Definition: main.c:60
DMA_HandleTypeDef hdma_adc3
Definition: AnalogSensor.h:69
uint32_t adc3_buffer[8]
Definition: main.c:115
float getAnalogSensorData(AnalogSensor *sensor)
Retrieves analog sensor data for a specific channel.
Definition: AnalogSensor.c:89
void ProcessADCData(uint32_t *adc1_buffer, uint32_t *adc2_buffer, uint32_t *adc3_buffer)
Processes ADC data from all three ADCs and stores it in the circular buffer.
Definition: AnalogSensor.c:58
uint32_t adc1_buffer[7]
Definition: main.c:113
ADC_HandleTypeDef hadc3
Definition: AnalogSensor.h:68
void initAnalogSensor(AnalogSensor *analogSensor, const char *name, int hz, int channel, void *child)
Initializes an analog sensor and configures the corresponding GPIO pin.
Definition: AnalogSensor.c:42
ADC_HandleTypeDef hadc2
Definition: AnalogSensor.h:68
DMA_HandleTypeDef hdma_adc2
Definition: AnalogSensor.h:69
uint32_t adc2_buffer[7]
Definition: main.c:114
void * child
Definition: AnalogSensor.h:25
Sensor sensor
Definition: AnalogSensor.h:23
Definition: Sensor.h:14