Skip to content

Commit

Permalink
Merge pull request cr1901#12 from Amanita-muscaria/master
Browse files Browse the repository at this point in the history
Add ability to set eeprom values
  • Loading branch information
cr1901 authored Jun 20, 2021
2 parents 47bcd5d + 120e414 commit 2e6ff2b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extern crate libftdi1_sys as ftdic;

pub use ftdic::ftdi_eeprom_value;
use std::ffi::{CStr, CString};
use std::marker::PhantomData;
use std::os::raw;
Expand Down Expand Up @@ -485,6 +486,15 @@ impl Device {
})
}

pub fn set_eeprom_value(&mut self, value_name: ftdi_eeprom_value, value: i32) -> Result<u32> {
let rc = unsafe {
ftdic::ftdi_set_eeprom_value(self.context.get_ftdi_context(), value_name, value)
};
self.context.check_ftdi_error(rc)?;
self.eeprom_read = false;
Ok(rc as u32)
}

/// Close device
pub fn close(self) -> Result<()> {
let rc = unsafe { ftdic::ftdi_usb_close(self.context.get_ftdi_context()) };
Expand Down

0 comments on commit 2e6ff2b

Please sign in to comment.