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, bp);
13 bp->pressure = -1;
15}
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
void updateBrakePressure(void *bp)
Updates the brake pressure data.
Definition: BrakePressure.c:21
Sensor sensor
Definition: AnalogSensor.h:23
AnalogSensor base
Definition: BrakePressure.h:7
Updateable updateable
Definition: Sensor.h:15
int(* update)(struct Updateable *self)
Definition: Updateable.h:27
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 31 of file BrakePressure.c.

31 {
32 if (rawVal < kLowOutputSaturation) {
33
34 #ifdef DEBUGn
35 printf("BrakePressure::transfer_function rawVal is too low\r\n");
36 #endif
37
38 return -1;
39 }
40 else if (rawVal > kHighOutputSaturation) {
41
42 #ifdef DEBUGn
43 printf("BrakePressure::transfer_function rawVal is too high\r\n");
44 #endif
45
46 return 2001;
47 }
48 else {
49 return ((rawVal - kOffsetVoltage) / kVoltsPerPSIA);
50 }
51}
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 = getAnalogSensorData(&brakePressure->base);
24
25 #ifdef DEBUGn
26 printf("BrakePressure::update rawVal: %f\r\n", rawData);
27 #endif
28 brakePressure->pressure = transferFunctionBrakePressure(rawData);
29}
float getAnalogSensorData(AnalogSensor *sensor)
Retrieves analog sensor data for a specific channel.
Definition: AnalogSensor.c:89
float transferFunctionBrakePressure(float rawVal)
Converts raw brake pressure data to a meaningful pressure value.
Definition: BrakePressure.c:31
Here is the call graph for this function:
Here is the caller graph for this function: