Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Functions
DigitalOutput.c File Reference
#include "../../Inc/Outputs/DigitalOutput.h"
#include "../../Inc/Utils/Common.h"
Include dependency graph for DigitalOutput.c:

Go to the source code of this file.

Functions

void initDigitalOutput (DigitalOutput *digitalOutput, const char *name, int hz, int port)
 Initializes a digital output with the given parameters. More...
 
int writeDigitalOutputData (DigitalOutput *output, int data)
 Writes data to the buffer of the digital output. More...
 

Function Documentation

◆ initDigitalOutput()

void initDigitalOutput ( DigitalOutput digitaloutput,
const char *  name,
int  hz,
int  port 
)

Initializes a digital output with the given parameters.

Parameters
digitaloutputPointer to the Output structure to initialize.
namePointer to a string containing the name of the output.
hzThe frequency in Hertz at which the output operates.
portLocation of the digital output on board.

Definition at line 4 of file DigitalOutput.c.

5 {
6 if (port < 0 || port >= NUM_DIGITAL_OUTPUTS) {
7
8 #ifdef DEBUGn
9 printf("Invalid port number for digital output %s\n", name);
10 #endif
11
12 return;
13 }
14 initOutput(&digitalOutput->output, name, hz, o_DIGITAL);
15 digitalOutput->port = port;
16}
#define NUM_DIGITAL_OUTPUTS
Definition: Constants.h:13
@ o_DIGITAL
Definition: Output.h:11
void initOutput(Output *output, const char *name, int hz, OutputType type)
Initializes an output with the given parameters.
Definition: Output.c:4
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeDigitalOutputData()

int writeDigitalOutputData ( DigitalOutput output,
int  data 
)

Writes data to the buffer of the digital output.

Parameters
outputPointer to the DigitalOutput structure.
dataData to write to the output.
Returns
int _SUCCESS or _FAILURE.

Definition at line 18 of file DigitalOutput.c.

18 {
19
20 #ifdef DEBUGn
21 printf("Writing data to digital output %s: %d\n", output->output.updateable.name, data);
22 #endif
23 digital_out_buffer[output->port] = data;
24 return _SUCCESS;
25}
#define _SUCCESS
Definition: Common.h:5
uint8_t digital_out_buffer[NUM_DIGITAL_OUTPUTS]
Definition: main.c:118
Updateable updateable
Definition: Output.h:15
char name[MAX_NAME_LENGTH]
Definition: Updateable.h:24
Here is the caller graph for this function: