Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Classes | Functions
BrakePressure.h File Reference
#include "../AnalogSensor.h"
Include dependency graph for BrakePressure.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BrakePressure
 

Functions

void initBrakePressure (BrakePressure *bp, int hz, int channel)
 Initializes the BrakePressure sensor with the given frequency and channel. More...
 
float getBrakePressure (BrakePressure *bp)
 Gets the current brake pressure. More...
 
void updateBrakePressure (void *bp)
 Updates the brake pressure data. More...
 
float transferFunctionBrakePressure (float rawVal)
 Converts raw brake pressure data to a meaningful pressure value. More...
 

Function Documentation

◆ getBrakePressure()

float getBrakePressure ( BrakePressure bp)

Gets the current brake pressure.

Parameters
bpPointer to the BrakePressure structure to query.
Returns
The current brake pressure.

Definition at line 17 of file BrakePressure.c.

17 {
18 return bp->pressure;
19}
Here is the caller graph for this function:

◆ initBrakePressure()

void initBrakePressure ( BrakePressure bp,
int  hz,
int  channel 
)

Initializes the BrakePressure sensor with the given frequency and channel.

Parameters
bpPointer to the BrakePressure structure to initialize.
hzThe frequency in Hertz at which the sensor operates.
channelThe analog channel the sensor is connected to.

Definition at line 11 of file BrakePressure.c.

11 {
12 initAnalogSensor(&bp->base, "BrakePressure", hz, channel);
13 bp->pressure = -1;
15}
void initAnalogSensor(AnalogSensor *analogSensor, const char *name, int hz, int channel)
Initializes an analog sensor and configures the corresponding GPIO pin.
Definition: AnalogSensor.c:44
void updateBrakePressure(void *bp)
Updates the brake pressure data.
Definition: BrakePressure.c:21
Sensor sensor
Definition: AnalogSensor.h:28
AnalogSensor base
Definition: BrakePressure.h:7
Updateable updateable
Definition: Sensor.h:15
void(* update)(void *self)
Definition: Updateable.h:26
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transferFunctionBrakePressure()

float transferFunctionBrakePressure ( float  rawVal)

Converts raw brake pressure data to a meaningful pressure value.

Parameters
rawValThe raw data from the brake pressure sensor.
Returns
The converted brake pressure value.

Definition at line 28 of file BrakePressure.c.

28 {
29 if (rawVal < kLowOutputSaturation) {
30 printf("BrakePressure::transfer_function rawVal is too low\n");
31 return -1;
32 }
33 else if (rawVal > kHighOutputSaturation) {
34 printf("BrakePressure::transfer_function rawVal is too high\n");
35 return 2001;
36 }
37 else {
38 return ((rawVal - kOffsetVoltage) / kVoltsPerPSIA);
39 }
40}
static const float kLowOutputSaturation
Definition: BrakePressure.c:8
static const float kHighOutputSaturation
Definition: BrakePressure.c:9
static const float kVoltsPerPSIA
Definition: BrakePressure.c:7
static const float kOffsetVoltage
Definition: BrakePressure.c:6
Here is the caller graph for this function:

◆ updateBrakePressure()

void updateBrakePressure ( void *  bp)

Updates the brake pressure data.

Parameters
bpPointer to the BrakePressure structure to update.

Definition at line 21 of file BrakePressure.c.

21 {
22 BrakePressure *brakePressure = (BrakePressure *)bp;
23 float rawData = 0.0f; // This should come from sensor read function or simulation
24 printf("Implement BrakePressure Update\n");
25 brakePressure->pressure = transferFunctionBrakePressure(rawData);
26}
float transferFunctionBrakePressure(float rawVal)
Converts raw brake pressure data to a meaningful pressure value.
Definition: BrakePressure.c:28
Here is the call graph for this function:
Here is the caller graph for this function: