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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! Driver for the iC-MD quadrature counter.
//! Built fully in Rust, uses [embedded_hal] and [device_driver].
//!
//! # Introduction
//!
//! The `IcMd` struct provides a high-level interface to interact with the iC-MD quadrature
//! counter. However, you can also access the underlying device driver directly via the `device`
//! field. Please read the device driver documentation for more information on what to expect
//! when interfacing with the device driver directly.
//! This low-level access is a temporary solution until the high-level interface is fully
//! developed. When this well be the case is unclear. If you are interested in it, please let me
//! know and I'm happy to prioritize the high-level features that are interesting to you.
//!
//! # Limitations
//!
//! The following capabilities are currently only accessible via the low-level interface:
//!
//! - Reference register readout: It is unclear if this currently works, see code comment.
//!
//! The following features are currently not yet implemented:
//!
//! - Differential or TTL inputs (Address 0x01, bit 7)
//! - Configuration to have Z signal clear counters 0 and/or 1 (Address 0x01, bits 5 and 6)
//! - Z signal configuration (Address 0x01, bits 3 and 4)
//! - Touch probe and AB registers (Address 0x01, bits 1 and 2)
//! - Differential input configuration selection (RS-422 (default) or LVDS) (Address 0x03, bit 7)
//!
//! # Example Usage
//!
//! This example requires the "blocking" feature to be activated, which it is by default.
//!
//! # use embedded_hal_mock::eh1::spi::{Mock, Transaction};
//! # use ic_md::IcMd;
//! # let expectations = [
//! # Transaction::transaction_start(),
//! # Transaction::write(0x00),
//! # Transaction::write(0x02),
//! # Transaction::transaction_end(),
//! # Transaction::transaction_start(),
//! # Transaction::write(0x80 | 0x08),
//! # Transaction::read_vec(vec![0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, 0xC0]),
//! # Transaction::transaction_end(),
//! # ];
//! // Initialize your SPIDevice, here we are mocking a device!
//! let mut spi_device = Mock::new(&expectations);
//!
//! // Get a handle to the counter with the default setup
//! let mut icmd = IcMd::new(&mut spi_device);
//!
//! // Initialize the counter
//! icmd.init().unwrap();
//!
//! // Read out the counter
//! let counter_value = icmd.read_counter().unwrap();
//!
//! // We can use the get counter methods to access the values. This will return an `Option`
//! // containing an `i64` value of the count (if the counter is setup, otherwise `None`).
//! let cnt_0 = counter_value
//! .get_cnt0()
//! .expect("Counter 0 should always be set up");
//!
//! assert_eq!(cnt_0, 42);
//!
//! // Last, let us ensure that there are no errors or warnings in the device status. We can use
//! // the `.is_ok()` method on the `DeviceStatus` struct to do this.
//! assert!(icmd.get_device_status().is_ok());
//! #
//! # // Check that all our expectations are met - testing only
//! # spi_device.done();
//! ```
//!
//! # Crate features
//!
//! By default, the blocking interface is activated (feature "blocking").
//! However, an async interface is also available when you activate the "async" feature.
//!
//! # Further help
//!
//! For further help and examples, please have a look at the `test` directory in the GitHub
//! repository, which you can find [here](https://github.com/trappitsch/ic-md/).
//! There you will find various integration tests that show how to use the driver in practice and
//! that contain detailed comments on for you.
pub use *;
pub use IcMd;
pub use IcMdAsync;