macro_rules! create_low_level_device { ( $(#[$device_doc:meta])* $device_name:ident { errors: [$($error_type:ident),*], hardware_interface_requirements: {$($hardware_interface_bound_type:tt)*}, hardware_interface_capabilities: $hardware_interface_capabilities:tt $(,)? } ) => { ... }; }
Expand description
The base macro for low level. Creates the struct and implements the right traits for it.
§Example
ⓘ
// Create our low level device. This holds all the hardware communication definitions
create_low_level_device!(
/// Our test device
MyDevice {
// The types of errors our low level error enum must contain
errors: [InterfaceError],
// Any hardware interface must implement the HardwareInterface trait that is created by this macro.
// This option allows us to specify which traits that new trait inherits. In this case that is RegisterInterface and Debug.
hardware_interface_requirements: { RegisterInterface + Debug },
// This specifies the contents of the HardwareInterface trait.
hardware_interface_capabilities: {
/// Resets the device
fn reset(&mut self) -> Result<(), InterfaceError>;
},
}
);