13
13
14
14
#include < modm/platform.hpp>
15
15
#include < modm/processing/fiber.hpp>
16
+ #include < modm/processing/timer/timeout.hpp>
16
17
#include < modm/architecture/interface/spi_device.hpp>
17
18
#include < modm/architecture/interface/accessor_flash.hpp>
18
19
#include < modm/debug/logger.hpp>
@@ -101,6 +102,11 @@ struct adns9800 {
101
102
};
102
103
MODM_FLAGS8 (ConfigurationII);
103
104
105
+ // Adns9800 takes periods up to 65535
106
+ using PeriodType = uint16_t ;
107
+ // The internal timer is running at 50MHz, hence the ratio:
108
+ using Duration = std::chrono::duration<PeriodType, std::ratio<1 , 50_MHz>>;
109
+
104
110
// forward declarations
105
111
struct Data ;
106
112
struct DataAndFaildetect ;
@@ -120,7 +126,6 @@ template <class SpiMaster, class Cs>
120
126
class Adns9800 : public adns9800 , public modm ::SpiDevice<SpiMaster> {
121
127
public:
122
128
static constexpr size_t FrameSize = 30 * 30 ; // Size of CMOS
123
-
124
129
/* *
125
130
* @brief ShutterConfig boundaries which may be selected by the automatic frame rate control.
126
131
* Periods are expressed as ticks of the device, running at 50MHz.
@@ -133,9 +138,6 @@ class Adns9800 : public adns9800, public modm::SpiDevice<SpiMaster> {
133
138
* @ingroup modm_driver_adns9800
134
139
*/
135
140
struct ShutterConfig {
136
- using PeriodType = uint16_t ;
137
- using Duration = std::chrono::duration<PeriodType, std::ratio<1 , 50_MHz>>;
138
-
139
141
PeriodType period_min, period_max, exposure_max;
140
142
141
143
// The datasheet refers to "wait for one frame" without better specification.
@@ -234,7 +236,7 @@ class Adns9800 : public adns9800, public modm::SpiDevice<SpiMaster> {
234
236
}
235
237
236
238
void
237
- set (const ShutterConfig shutter_new) {
239
+ set (ShutterConfig shutter_new) {
238
240
if (shutter_new.isValid ()) {
239
241
shutter_config = shutter_new;
240
242
@@ -252,8 +254,8 @@ class Adns9800 : public adns9800, public modm::SpiDevice<SpiMaster> {
252
254
253
255
// / In fixed framerate mode (Register ConfigurationII::Fixed_FrameRate: 1), period_max selects the framerate
254
256
void
255
- setFramePeriodMax (const uint16_t period_max) {
256
- const uint16_t recover = shutter_config.period_max ;
257
+ setFramePeriodMax (const PeriodType period_max) {
258
+ const PeriodType recover = shutter_config.period_max ;
257
259
shutter_config.period_max = period_max;
258
260
259
261
if (shutter_config.isValid ()) {
@@ -266,8 +268,8 @@ class Adns9800 : public adns9800, public modm::SpiDevice<SpiMaster> {
266
268
}
267
269
268
270
void
269
- setFramePeriodMin (const uint16_t period_min) {
270
- const uint16_t recover = shutter_config.period_min ;
271
+ setFramePeriodMin (const PeriodType period_min) {
272
+ const PeriodType recover = shutter_config.period_min ;
271
273
shutter_config.period_min = period_min;
272
274
273
275
if (shutter_config.isValid ()) {
@@ -280,8 +282,8 @@ class Adns9800 : public adns9800, public modm::SpiDevice<SpiMaster> {
280
282
}
281
283
282
284
void
283
- setExposureMax (const uint16_t shutter_max) {
284
- const uint16_t recover = shutter_config.shutter_max ;
285
+ setExposureMax (const PeriodType shutter_max) {
286
+ const PeriodType recover = shutter_config.shutter_max ;
285
287
shutter_config.shutter_max = shutter_max;
286
288
287
289
if (shutter_config.assert ()) {
@@ -413,7 +415,7 @@ class Adns9800 : public adns9800, public modm::SpiDevice<SpiMaster> {
413
415
});
414
416
modm::this_fiber::sleep_for (shutter_config.getOneFrameTime ());
415
417
416
- // Additionaly one could request a CRC check of the firmware. @see datasheet P31
418
+ // @optimize Request a CRC result of the firmware. @see datasheet P31
417
419
}
418
420
419
421
private:
0 commit comments