Skip to content

Commit

Permalink
#5: Removed trailing whitespace of main example doc
Browse files Browse the repository at this point in the history
  • Loading branch information
marius-meissner committed Oct 2, 2024
1 parent e8ca7f7 commit 66049d4
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@
//!## CAN TX/RX example
//!
//!```
//! use mcp2517::example::{ExampleClock,ExampleCSPin,ExampleSPIBus};
//! use mcp2517::can::{MCP2517,CanController};
//! use mcp2517::message::{Can20,TxMessage};
//! use mcp2517::filter::Filter;
//! use mcp2517::config::*;
//! use bytes::Bytes;
//! use embedded_can::{Id,StandardId};
//!use mcp2517::example::{ExampleClock,ExampleCSPin,ExampleSPIBus};
//!use mcp2517::can::{MCP2517,CanController};
//!use mcp2517::message::{Can20,TxMessage};
//!use mcp2517::filter::Filter;
//!use mcp2517::config::*;
//!use bytes::Bytes;
//!use embedded_can::{Id,StandardId};
//!
//!let cs_pin = ExampleCSPin{};
//!let spi_bus = ExampleSPIBus::default();
//!let clock = ExampleClock::default();
//!
//!let mut controller = MCP2517::new(spi_bus, cs_pin);
//! // configure CAN controller
//!
//!// configure CAN controller
//!controller
//! .configure(
//! &Configuration {
Expand All @@ -56,24 +57,27 @@
//! &clock,
//! ).unwrap();
//!
//! // Create message frame
//!// Create message frame
//!let can_id = Id::Standard(StandardId::new(0x55).unwrap());
//! // Important note: Generic arg for message type for CAN2.0
//! // should be either 4 or 8, the DLC will be based off the
//! // length of the payload buffer. So for a payload of 5 bytes
//! // you can only use Can20::<8> as the message type
//!
//!// Important note: Generic arg for message type for CAN2.0
//!// should be either 4 or 8, the DLC will be based off the
//!// length of the payload buffer. So for a payload of 5 bytes
//!// you can only use Can20::<8> as the message type
//!let message_type = Can20::<8> {};
//!let payload = [0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8];
//!let pl_bytes = Bytes::copy_from_slice(&payload);
//!let can_message = TxMessage::new(message_type, pl_bytes, can_id).unwrap();
//!
//!// Create and set filter object
//!let filter = Filter::new(can_id, 0).unwrap();
//!let _ = controller.set_filter_object(filter);
//!
//!// Transmit CAN message
//!controller.transmit(&can_message).unwrap();
//!
//!let mut buff = [0u8;8];
//!// Receive CAN message
//!let mut buff = [0u8;8];
//!let result = controller.receive(&mut buff);
//!assert!(result.is_ok());
//!assert_eq!(buff,[0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
Expand Down

0 comments on commit 66049d4

Please sign in to comment.