Skip to content

Commit

Permalink
Merge pull request #1 from klonyyy/devel
Browse files Browse the repository at this point in the history
Float values not being written correctly
  • Loading branch information
klonyyy authored Jun 12, 2023
2 parents 400d2f8 + 43d5c26 commit f3d976a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif()

project(STMViewer)

set(STMVIEWER_VERSION 0.1.0)
set(STMVIEWER_VERSION 0.1.1)

set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_STANDARD 17)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Windows:
1. Make sure you've got GDB installed and added to your PATH (the easiest way is to install using [MinGW](https://www.mingw-w64.org))
2. Download and run the STMViewer installer. Make sure the ST-link is in "STM32 Debug + Mass Storage + VCP" mode as for some reason "STM32 Debug + VCP" throws libusb errors on Windows. This needs further investigation.

You can assing the external GPU to STMViewer for improved performance.

## Quick Start

1. Open Options->Acqusition Settings window in the top menu.
Expand Down
Binary file modified docs/STMViewer.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 19 additions & 4 deletions src/VarReader/VarReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,44 +114,59 @@ bool VarReader::setValue(const Variable& var, double value)
switch (var.getType())
{
case Variable::type::U8:
{
sl->q_buf[0] = static_cast<uint8_t>(value);
retVal = stlink_write_mem8(sl, address, 1);
break;
}
case Variable::type::I8:
{
sl->q_buf[0] = static_cast<int8_t>(value);
retVal = stlink_write_mem8(sl, address, 1);
break;
}
case Variable::type::U16:
{
sl->q_buf[0] = static_cast<uint16_t>(value);
sl->q_buf[1] = static_cast<uint16_t>(value) >> 8;
retVal = stlink_write_mem8(sl, address, 2);
break;
}
case Variable::type::I16:
{
sl->q_buf[0] = static_cast<int16_t>(value);
sl->q_buf[1] = static_cast<int16_t>(value) >> 8;
retVal = stlink_write_mem8(sl, address, 2);
break;
}
case Variable::type::U32:
{
sl->q_buf[0] = static_cast<uint32_t>(value);
sl->q_buf[1] = static_cast<uint32_t>(value) >> 8;
sl->q_buf[2] = static_cast<uint32_t>(value) >> 16;
sl->q_buf[3] = static_cast<uint32_t>(value) >> 24;
retVal = stlink_write_mem8(sl, address, 4);
break;
}
case Variable::type::I32:
{
sl->q_buf[0] = static_cast<uint32_t>(value);
sl->q_buf[1] = static_cast<uint32_t>(value) >> 8;
sl->q_buf[2] = static_cast<uint32_t>(value) >> 16;
sl->q_buf[3] = static_cast<uint32_t>(value) >> 24;
retVal = stlink_write_mem8(sl, address, 4);
break;
}
case Variable::type::F32:
sl->q_buf[0] = (*(uint32_t*)&value);
sl->q_buf[1] = (*(uint32_t*)&value) >> 8;
sl->q_buf[2] = (*(uint32_t*)&value) >> 16;
sl->q_buf[3] = (*(uint32_t*)&value) >> 24;
{
float val = static_cast<float>(value);
sl->q_buf[0] = (*(uint32_t*)&val);
sl->q_buf[1] = (*(uint32_t*)&val) >> 8;
sl->q_buf[2] = (*(uint32_t*)&val) >> 16;
sl->q_buf[3] = (*(uint32_t*)&val) >> 24;
retVal = stlink_write_mem8(sl, address, 4);
break;
}
default:
return false;
}
Expand Down

0 comments on commit f3d976a

Please sign in to comment.