Vehicle Control Unit 0.01
This is the c library for controlling the car.
|
#include "stm32f7xx.h"
#include "stm32f7xx_hal.h"
#include "stm32f7xx_hal_adc.h"
#include "stm32f7xx_hal_dma.h"
#include "stm32f7xx_hal_uart.h"
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "Sensor.h"
Go to the source code of this file.
Classes | |
struct | AnalogSensor |
Functions | |
void | initAnalogSensor (AnalogSensor *analogSensor, const char *name, int hz, int channel, void *child) |
Initializes an analog sensor and configures the corresponding GPIO pin. More... | |
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. More... | |
float | getAnalogSensorData (AnalogSensor *sensor) |
Retrieves analog sensor data for a specific channel. More... | |
Variables | |
ADC_HandleTypeDef | hadc1 |
ADC_HandleTypeDef | hadc2 |
ADC_HandleTypeDef | hadc3 |
DMA_HandleTypeDef | hdma_adc1 |
DMA_HandleTypeDef | hdma_adc2 |
DMA_HandleTypeDef | hdma_adc3 |
uint32_t | adc1_buffer [7] |
uint32_t | adc2_buffer [7] |
uint32_t | adc3_buffer [8] |
float getAnalogSensorData | ( | AnalogSensor * | sensor | ) |
Retrieves analog sensor data for a specific channel.
sensor | Pointer to the AnalogSensor structure |
This function returns the latest ADC value for the channel specified in the AnalogSensor structure. If an invalid channel is specified, it returns 0.
sensor | Pointer to the AnalogSensor structure |
This function returns the latest ADC value for the channel specified in the AnalogSensor structure. If an invalid channel is specified, it returns 0.
Definition at line 89 of file AnalogSensor.c.
void initAnalogSensor | ( | AnalogSensor * | analogSensor, |
const char * | name, | ||
int | hz, | ||
int | channel, | ||
void * | child | ||
) |
Initializes an analog sensor and configures the corresponding GPIO pin.
sensor | Pointer to the AnalogSensor structure to initialize |
name | Name of the sensor (string) |
hz | Sampling frequency in Hertz |
channel | ADC channel number for the sensor (0-16) |
This function initializes the base sensor properties, sets the ADC channel, and configures the corresponding GPIO pin based on the channel number.
sensor | Pointer to the AnalogSensor structure to initialize |
name | Name of the sensor (string) |
hz | Sampling frequency in Hertz |
channel | ADC channel number for the sensor (0-16) |
This function initializes the base sensor properties, sets the ADC channel, and configures the corresponding GPIO pin based on the channel number.
Definition at line 42 of file AnalogSensor.c.
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.
adc1_data | Pointer to ADC1 data buffer (channels 0-5) |
adc2_data | Pointer to ADC2 data buffer (channels 6-11) |
adc3_data | Pointer to ADC3 data buffer (channels 12-15) |
This function combines data from all three ADCs into a single ADCSample and adds it to the circular buffer. It also sends debug information via UART.
adc1_data | Pointer to ADC1 data buffer (channels 0-5) |
adc2_data | Pointer to ADC2 data buffer (channels 6-11) |
adc3_data | Pointer to ADC3 data buffer (channels 12-15) |
This function combines data from all three ADCs into a single ADCSample and adds it to the circular buffer. It also sends debug information via UART.
Definition at line 58 of file AnalogSensor.c.
ADC_HandleTypeDef hadc2 |
Definition at line 68 of file AnalogSensor.h.
ADC_HandleTypeDef hadc3 |
Definition at line 68 of file AnalogSensor.h.
DMA_HandleTypeDef hdma_adc2 |
Definition at line 69 of file AnalogSensor.h.
DMA_HandleTypeDef hdma_adc3 |
Definition at line 69 of file AnalogSensor.h.