Skip to content

Commit bf23c41

Browse files
committed
Created seperate pair of pressure files
1 parent 764b033 commit bf23c41

File tree

6 files changed

+61
-19
lines changed

6 files changed

+61
-19
lines changed

Common/Inc/config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
// BEGIN KELLY DEFS
2626
// FRAME 1
27-
const Data_Segment_t DRIVING_DIRECTION_K = {MOTOR_CONTROLLER_1, 1, 1};
28-
const Data_Segment_t MOTOR_SPEED_K = {MOTOR_CONTROLLER_1, 2, 3};
29-
const Data_Segment_t MOTOR_ERROR_CODE_K = {MOTOR_CONTROLLER_1, 4, 4};
27+
const Data_Segment_t DRIVING_DIRECTION_K = {MOTOR_CONTROLLER_K1, 1, 1};
28+
const Data_Segment_t MOTOR_SPEED_K = {MOTOR_CONTROLLER_K1, 2, 3};
29+
const Data_Segment_t MOTOR_ERROR_CODE_K = {MOTOR_CONTROLLER_K1, 4, 4};
3030
// FRAME 2
3131
const Data_Segment_t BATTERY_VOLTAGE_K = {MOTOR_CONTROLLER_K2, 1, 2};
3232
const Data_Segment_t BATTERY_CURRENT_K = {MOTOR_CONTROLLER_K2, 3, 4};

Sensors/.cproject

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,12 @@
175175
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/>
176176
</scannerConfigBuildInfo>
177177
</storageModule>
178-
<storageModule moduleId="refreshScope"/>
178+
<storageModule moduleId="refreshScope" versionNumber="2">
179+
<configuration configurationName="Debug">
180+
<resource resourceType="PROJECT" workspacePath="/Sensors"/>
181+
</configuration>
182+
<configuration configurationName="Release">
183+
<resource resourceType="PROJECT" workspacePath="/Sensors"/>
184+
</configuration>
185+
</storageModule>
179186
</cproject>

Sensors/.project

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@
2929
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
3030
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
3131
</natures>
32+
<linkedResources>
33+
<link>
34+
<name>Common</name>
35+
<type>2</type>
36+
<location>C:/Users/mahir/Desktop/Waterloop/G6-STM32/Common</location>
37+
</link>
38+
</linkedResources>
3239
</projectDescription>

Sensors/Core/Inc/pressure.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* pressure.h
3+
*
4+
* Created on: Apr 25, 2024
5+
* Author: mahesh, mahir
6+
*/
7+
8+
#ifndef INC_PRESSURE_H_
9+
#define INC_PRESSURE_H_
10+
11+
#include <stdint.h>
12+
#define MAX_ADC_VALUE 4095
13+
14+
uint8_t poll_pressure_sensor(void);
15+
16+
#endif /* INC_PRESSURE_H_ */

Sensors/Core/Src/main.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "can_driver.h"
2929
#include "config.h"
3030
#include "mpu6050.h"
31-
31+
#include "pressure.h"
3232
/* USER CODE END Includes */
3333

3434
/* Private typedef -----------------------------------------------------------*/
@@ -49,25 +49,13 @@
4949
/* Private variables ---------------------------------------------------------*/
5050

5151
/* USER CODE BEGIN PV */
52-
uint32_t rawPressureSensorValue;
53-
float fCalculatedVoltageFromRawPressureSensorVal;
52+
5453
/* USER CODE END PV */
5554

5655
/* Private function prototypes -----------------------------------------------*/
5756
void SystemClock_Config(void);
5857
/* USER CODE BEGIN PFP */
59-
uint8_t poll_Pressure_Sensor(void){
60-
HAL_ADC_PollForConversion(&hadc1,1000); // I haven't used HAL_MAX_DELAY here because we will be polling two more sensors after the pressure sensor, and waiting for an ADC conversion here indefinitely will result in the next two sensors not being read.
61-
rawPressureSensorValue = HAL_ADC_GetValue(&hadc1);
62-
//rawPressureSensorValue will be between 0 and 4095.
63-
fCalculatedVoltageFromRawPressureSensorVal = rawPressureSensorValue * (3.3/4095.0);
64-
//we now have a voltage between 0 and 3.3V
65-
HAL_Delay(200);
66-
//right now, I will configure this function to return the voltage itself
67-
//later on, we need to edit this to return the pressure
68-
//the pressure can be easily calculated from the voltage.
69-
return (uint8_t)fCalculatedVoltageFromRawPressureSensorVal;
70-
}
58+
7159
/* USER CODE END PFP */
7260

7361
/* Private user code ---------------------------------------------------------*/

Sensors/Core/Src/pressure.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* pressure.c
3+
*
4+
* Created on: Apr 25, 2024
5+
* Author: mahesh, mahir
6+
*/
7+
8+
#include "pressure.h"
9+
#include "adc.h"
10+
11+
uint8_t poll_pressure_sensor(void){
12+
/*
13+
* I haven't used HAL_MAX_DELAY here because we will be polling
14+
* two more sensors after the pressure sensor, and waiting for an
15+
* ADC conversion here indefinitely will result in delays.
16+
*/
17+
HAL_ADC_PollForConversion(&hadc1,1000);
18+
uint32_t raw_pressure_sensor_value = HAL_ADC_GetValue(&hadc1);
19+
20+
//rawPressureSensorValue will be between 0 and 4095.
21+
uint8_t pressure = (raw_pressure_sensor_value/MAX_ADC_VALUE);
22+
23+
return pressure;
24+
}

0 commit comments

Comments
 (0)