aboutsummaryrefslogtreecommitdiffstats
path: root/source/sclock.hpp
diff options
context:
space:
mode:
authorclyne <clyne@bitgloo.com>2021-03-21 16:34:21 -0400
committerGitHub <noreply@github.com>2021-03-21 16:34:21 -0400
commit9b926b81ef1e8a4c7266494ae2a1369380e01b35 (patch)
tree746095fa69eccccdc1c2830fdd0c06bac01848f5 /source/sclock.hpp
parente080a26651f90c88176140d63a74c93c2f4041a2 (diff)
parenta4f1482a8b23d5f761f60d6f3821c84190d89e2f (diff)
Merge pull request #3 from tcsullivan/stm32h7
Stm32h7
Diffstat (limited to 'source/sclock.hpp')
-rw-r--r--source/sclock.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/source/sclock.hpp b/source/sclock.hpp
new file mode 100644
index 0000000..960d9e3
--- /dev/null
+++ b/source/sclock.hpp
@@ -0,0 +1,36 @@
+#ifndef SCLOCK_HPP_
+#define SCLOCK_HPP_
+
+#include "hal.h"
+
+#include <array>
+
+class SClock
+{
+public:
+ enum class Rate : unsigned int {
+ R8K = 0,
+ R16K,
+ R20K,
+ R32K,
+ R48K,
+ R96K
+ };
+
+ static void begin();
+ static void start();
+ static void stop();
+
+ static void setRate(Rate rate);
+ static unsigned int getRate();
+
+private:
+ static GPTDriver *m_timer;
+ static unsigned int m_div;
+ static unsigned int m_runcount;
+ static const GPTConfig m_timer_config;
+ static const std::array<unsigned int, 6> m_rate_divs;
+};
+
+#endif // SCLOCK_HPP_
+