aboutsummaryrefslogtreecommitdiffstats
path: root/gui/stmdsp.hpp
blob: 06d36ba0324ef1fb968db286b861a8bbd54bb5ae (plain)
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
#ifndef STMDSP_HPP_
#define STMDSP_HPP_

#include <cstdint>
#include <list>
#include <serial/serial.h>
#include <string>

namespace stmdsp
{
    class scanner
    {
    private:
        constexpr static const char *STMDSP_USB_ID = "USB VID:PID=0483:5740";

    public:
        std::list<std::string>& scan();
        auto& devices() {
            return m_available_devices;
        }

    private:
        std::list<std::string> m_available_devices;
    };

    using adcsample_t = uint16_t;

    class device
    {
    public:
        device(const std::string& file);

        ~device() {
            m_serial.close();
        }

        bool connected() {
            return m_serial.isOpen();
        }

        std::vector<adcsample_t> sample(unsigned long int count = 1);

        void continuous_start();
        void continuous_start_measure();
        uint32_t continuous_start_get_measurement();
        std::vector<adcsample_t> continuous_read();
        void continuous_stop();

        void upload_filter(unsigned char *buffer, size_t size);
        void unload_filter();

    private:
        serial::Serial m_serial;
    };
}

#endif // STMDSP_HPP_