aboutsummaryrefslogtreecommitdiffstats
path: root/source/stmdsp/stmdsp.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2021-10-05 19:59:20 -0400
committerClyne Sullivan <clyne@bitgloo.com>2021-10-05 19:59:20 -0400
commita4e2375f049d3949c1a4b9a044d3d1efc6fa7d62 (patch)
tree54516765cd7bb73e136a90abf23fffaeed73f5ca /source/stmdsp/stmdsp.cpp
parent9f480396204e8ccdd89779860cb61d4e4aded8b4 (diff)
draw samples: set time frame
Diffstat (limited to 'source/stmdsp/stmdsp.cpp')
-rw-r--r--source/stmdsp/stmdsp.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/source/stmdsp/stmdsp.cpp b/source/stmdsp/stmdsp.cpp
index bb417ca..93c52dd 100644
--- a/source/stmdsp/stmdsp.cpp
+++ b/source/stmdsp/stmdsp.cpp
@@ -30,18 +30,18 @@ namespace stmdsp
m_serial(file, 8'000'000/*230400*/, serial::Timeout::simpleTimeout(50))
{
if (m_serial.isOpen()) {
- m_serial.flush();
- m_serial.write("i");
- if (auto id = m_serial.read(7); id.starts_with("stmdsp")) {
+ m_serial.flush();
+ m_serial.write("i");
+ if (auto id = m_serial.read(7); id.starts_with("stmdsp")) {
if (id.back() == 'h')
m_platform = platform::H7;
else if (id.back() == 'l')
m_platform = platform::L4;
else
m_serial.close();
- } else {
- m_serial.close();
- }
+ } else {
+ m_serial.close();
+ }
}
}
@@ -69,17 +69,18 @@ namespace stmdsp
}
unsigned int device::get_sample_rate() {
- unsigned char result = 0xFF;
-
- if (connected()) {
+ if (connected() && !is_running()) {
uint8_t request[2] = {
'r', 0xFF
};
m_serial.write(request, 2);
+
+ unsigned char result = 0xFF;
m_serial.read(&result, 1);
+ m_sample_rate = result;
}
- return result;
+ return m_sample_rate;
}
void device::continuous_start() {