Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Imd.c
Go to the documentation of this file.
1#include "../../../Inc/Systems/External/Imd.h"
2#include "../../../Inc/Systems/ExternalSystem.h"
3#include "../../../Inc/Utils/Updateable.h"
4#include "../../../Inc/Utils/Common.h"
5
6void initIMD(IMDValues* IMD, int hz) {
7 initExternalSystem(&IMD->base, "IMD", hz, EXTERNAL, NULL, NULL, IMD);
8 IMD->base.system.updateable.update = updateIMD;
9 // IMD->base.system.updateable.status = getIMDStatus; // FIXME: Update getIMDStatus
10 IMD->IMDStatus = IMD_OK;
11 IMD->IsoResistanceNeg = 0;
12 IMD->IsoResistancePos = 0;
13 IMD->IsoResistanceCorrected = 0;
14}
15
16int updateIMD(Updateable* updateable) {
17 //TODO: Implement logic to determine IMD status
18 /*if (something){
19 set IMD_ERROR;
20 } else if (something){
21 set IMD_START;
22 } else {*/
23 // set IMD_OK
24 return _FAILURE;
25}
26
27int getIMDStatus(void* imdValues, IMDStatus status) {
28 IMDValues* IMD = (IMDValues*) imdValues;
29 return IMD->IMDStatus;
30}
31
32float getIsoResistanceNeg (void* imdValues) {
33 IMDValues* IMD = (IMDValues*) imdValues;
34 return IMD->IsoResistanceNeg;
35}
36
37float getIsoResistancePos (void* imdValues) {
38 IMDValues* IMD = (IMDValues*) imdValues;
39 return IMD->IsoResistancePos;
40}
41
42float getIsoResistanceCorrected (void* imdValues) {
43 IMDValues* IMD = (IMDValues*) imdValues;
44 return IMD->IsoResistanceCorrected;
45}
46
#define _FAILURE
Definition: Common.h:6
void initExternalSystem(ExternalSystem *external, const char *name, int hz, ExternalType type, int(*updateExternal)(ExternalSystem *external), int(*check_heartbeat)(void *self), void *child)
Definition: ExternalSystem.c:6
@ IMD
int updateIMD(Updateable *updateable)
Updates the IMD values.
Definition: Imd.c:16
float getIsoResistancePos(void *imdValues)
Retrieves the positive isolation resistance value from the IMD values.
Definition: Imd.c:37
void initIMD(IMDValues *IMD, int hz)
Initializes the IMD with the specified frequency.
Definition: Imd.c:6
float getIsoResistanceNeg(void *imdValues)
Retrieves the negative isolation resistance value from the given IMD values.
Definition: Imd.c:32
float getIsoResistanceCorrected(void *imdValues)
Retrieves the positive isolation resistance value from the IMD values.
Definition: Imd.c:42
int getIMDStatus(void *imdValues, IMDStatus status)
Gets the status of the IMD.
Definition: Imd.c:27
IMDStatus
Definition: Imd.h:7
@ IMD_OK
Definition: Imd.h:8
@ EXTERNAL
Definition: System.h:12
Definition: Imd.h:13