Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Inc/pressure_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace PressureConversions {
}

constexpr uint32_t voltageToPascals(uint32_t voltage_mv) noexcept {
return voltage_mv * 6895u / 4u * 37u / 9u;
return voltage_mv * 68950u / 4u * 37u / 9u;
}

constexpr uint32_t pascalsToDepthMm(uint32_t pascals) noexcept {
Expand Down
15 changes: 11 additions & 4 deletions Core/Src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "C" {
#include "hydrolib_bus_application_master.hpp"


#define BUFFER_LENGTH 5 // TODO:make variable
constexpr uint32_t kTransmitPeriodMs = 5; // 200 Hz

constinit hydrv::GPIO::GPIOLow rx_pin(hydrv::GPIO::GPIOLow::GPIOA_port, 10,
hydrv::GPIO::GPIOLow::GPIO_UART_RX);
Expand Down Expand Up @@ -105,12 +105,19 @@ int main(void) {
/* USER CODE BEGIN 2 */
sensor.init();
RS.Init();


uint32_t lastTransmitTick = HAL_GetTick();

while (1) {
manager.Process();
sensor.poll();
depth = sensor.getDepthMm();
master.Write(static_cast<void*>(&depth), 0, sizeof(depth));

const uint32_t now = HAL_GetTick();
if (now - lastTransmitTick >= kTransmitPeriodMs) {
lastTransmitTick = now;
master.Write(static_cast<void*>(&depth), 0, sizeof(depth));
}
}
/* USER CODE END 3 */
}
Expand All @@ -129,7 +136,7 @@ void SystemClock_Config(void) {
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV2;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
Expand Down
Loading