Skip to content

Commit

Permalink
fix README
Browse files Browse the repository at this point in the history
  • Loading branch information
hacknus committed Oct 13, 2023
1 parent 45ce66e commit 91dab3b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Put this into your `cargo.toml`:
```toml
[dependencies]
tmc5160 = { git = "https://github.com/hacknus/tmc5160-rs" }
# required for the register configs to_u32() function
# required for the register configs to_u32_le() function
modular-bitfield-to-value = {git = "https://github.com/hacknus/modular-bitfield-to-value"}
```
Add the following imports:
```rust
use tmc5160::registers::*;
use tmc5160::{DataPacket, Error, Tmc5160};

// required for the to_u32() function.
// required for the to_u32_le() function.
use modular_bitfield_to_value::ToValue;
```

Expand Down Expand Up @@ -77,7 +77,7 @@ and to use the driver, implement the driver as shown below:
.set_en_pwm_mode(true);
match stepper_driver.update_g_conf(){
Ok(packet) => {
sprintln!(in_out, "SPI status has been updated: {}", packet.status);
sprintln!(in_out, "SPI status has been updated: {}", packet.status.to_u32_le().unwrap_or(0));
}
Err(error) => {
sprintln!(in_out, "Error for read status is {:?}", error);
Expand All @@ -87,10 +87,10 @@ and to use the driver, implement the driver as shown below:
match stepper_driver.read_drv_status() {
Ok(status) => {
// either use fields of the register
sprintln!(in_out, "Stepper driver is in standstill: {}", status);
sprintln!(in_out, "Stepper driver is in standstill: {}", status.standstill());
// or extract the u32 value from the register
sprintln!(in_out, "Stepper driver DRV_STATUS register is {}", status.to_u32().unwrap_or(0));
sprintln!(in_out, "SPI status has been updated: {}", stepper_driver.status);
sprintln!(in_out, "Stepper driver DRV_STATUS register is {}", status.to_u32_le().unwrap_or(0));
sprintln!(in_out, "SPI status has been updated: {}", stepper_driver.status.to_u32_le().unwrap_or(0));
}
Err(error) => {
sprintln!(in_out, "Error for read status is {:?}", error);
Expand All @@ -100,8 +100,8 @@ and to use the driver, implement the driver as shown below:
match stepper_driver.read_gstat() {
Ok(status) => {
Ok(status) => {
sprintln!(in_out, "Stepper GSTAT register is {}", status.to_u32().unwrap_or(0));
sprintln!(in_out, "SPI status has been updated: {}", stepper_driver.status);
sprintln!(in_out, "Stepper GSTAT register is {}", status.to_u32_le().unwrap_or(0));
sprintln!(in_out, "SPI status has been updated: {}", stepper_driver.status.to_u32_le().unwrap_or(0));
}
Err(error) => {
sprintln!(in_out, "Error for read status is {:?}", error);
Expand Down

0 comments on commit 91dab3b

Please sign in to comment.