Repository navigation
Expand file tree
/
Copy pathSensorInt.c
More file actions
70 lines (48 loc) · 1.46 KB
/
Copy pathSensorInt.c
File metadata and controls
70 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "SensorInt.h"
void SensorInt_Construct(ClassSensorInt * sensorInt, enum SensorsVector sensor,
uint32_t ctlFS, char ID) {
sensorInt->_FS = ctlFS;
sensorInt->_sensor = sensor;
sensorInt->_value = 0;
IOPorts_Construct(&sensorInt->_IOPorts, 0, 1, &sensorInt->_value);
CtlHandler_Construct(&sensorInt->_handler, (void*) sensorInt,
&sensorInt->_IOPorts, ID, SensorInt_Compute, SensorInt_Reset, &sensorInt->_FS);
}
void SensorInt_Compute(void * SensorIntV) {
ClassSensorInt * sensorInt = (ClassSensorInt *) SensorIntV;
switch (sensorInt->_sensor) {
case QEI_POS:
sensorInt->_value = QEI_GetPosRad();
break;
case QEI_SPEED:
sensorInt->_value = QEI_GetSpeedRadSec();
break;
case CURRENT:
sensorInt->_value = CurrentT_GetCurrent();
break;
case FORCE:
sensorInt->_value = ForceT_GetForce();
break;
default:
break;
}
}
void SensorInt_Reset(void * SensorIntV) {
SensorInt_Compute(SensorIntV);
// ClassSensorInt * sensorInt = (ClassSensorInt *) SensorIntV;
//
// sensorInt->_value = 0;
}
// Parameters Setters
void SensorInt_SetFS(ClassSensorInt * sensorInt, uint32_t ctlFS) {
sensorInt->_FS = ctlFS;
}
// Parameters
uint32_t SensorInt_GetFS(void * sensorIntV) {
ClassSensorInt * sensorInt = (ClassSensorInt *) sensorIntV;
return sensorInt->_FS;
}
// Variables
float SensorInt_GetValue(ClassSensorInt * sensorInt) {
return *IOPorts_GetOutPort(&sensorInt->_IOPorts);
}