Skip to content

Commit

Permalink
Allow access sur uart through JSY to change baudrate
Browse files Browse the repository at this point in the history
  • Loading branch information
emeric-martineau committed Sep 1, 2024
1 parent 0ed906c commit 2431cc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jsy_mk_194"
version = "1.0.1"
version = "1.0.3"
authors = ["Emeric Martineau <[email protected]>"]
edition = "2021"
resolver = "2"
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ That's all!

## Changelog

### 1.0.3

- Allow update UART after change bitrate

### 1.0.2

DON'T USE IT. IT'S MISTAKE

### 1.0.1

- Rewrite module to be more easy to understand
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
//! | 16 | crc | 59, 60 |
//!
use embedded_hal::blocking::delay::DelayMs;
use error::UartError;

pub mod error;
#[cfg(test)]
Expand Down Expand Up @@ -144,6 +145,9 @@ pub trait Uart {

/// Write multiple bytes from a slice
fn write(&mut self, bytes: &[u8]) -> Result<usize, error::UartError>;

/// Allow change uart config
fn change_baudrate(&mut self, f: u32) -> Result<(), error::UartError> ;
}

/// Channel struct to get information. JSY MK 194 has 2 channels
Expand Down Expand Up @@ -348,6 +352,10 @@ where
}
}

pub fn change_baudrate(&mut self, f: u32) -> Result<(), UartError> {
self.uart.change_baudrate(f)
}

fn update_segment(
&self,
data: &mut [u8; SEGMENT_WRITE_CHANGE_BIT_RATE],
Expand Down

0 comments on commit 2431cc1

Please sign in to comment.