Skip to content

Commit

Permalink
Add an option to disable the event readout
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarcireau committed Sep 27, 2023
1 parent 08d1dfd commit 6702f36
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion drivers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = [
"Alexandre Marcireau",
]
description = "Neuromorphic devices drivers"
version = "0.7.0"
version = "0.8.0"
edition = "2021"
license-file = "../LICENSE"
homepage = "https://github.com/neuromorphicsystems/neuromorphic-rs/"
Expand Down
5 changes: 3 additions & 2 deletions drivers/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ pub trait Usb: Sized {

const DEFAULT_USB_CONFIGURATION: usb::Configuration;

// read_serial must claim bulk transfer interface(s)
// this is required even if read_serial does not use bulk transfers
/// read_serial must claim bulk transfer interface(s).
///
/// This is required even if read_serial does not use bulk transfers.
fn read_serial(handle: &mut rusb::DeviceHandle<rusb::Context>) -> rusb::Result<String>;

fn update_configuration(&self, configuration: Self::Configuration);
Expand Down
40 changes: 36 additions & 4 deletions drivers/src/devices/prophesee_evk4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub struct Configuration {
pub enable_external_trigger: bool,
pub clock: Clock,
pub rate_limiter: Option<RateLimiter>,
pub enable_output: bool,
}

pub struct Device {
Expand Down Expand Up @@ -119,6 +120,7 @@ impl device::Usb for Device {
enable_external_trigger: true,
clock: Clock::Internal,
rate_limiter: None,
enable_output: true,
},
};

Expand Down Expand Up @@ -276,7 +278,11 @@ impl device::Usb for Device {
}
.write(&handle)?;
Unknown002C { value: 0x0022c324 }.write(&handle)?;
RoCtrl { value: 0x00000002 }.write(&handle)?;
RoCtrl {
area_count_enable: 0,
output_disable: 1,
keep_timer_high: 0,
}.write(&handle)?;
std::thread::sleep(std::time::Duration::from_millis(1));
TimeBaseCtrl {
enable: 0,
Expand Down Expand Up @@ -607,7 +613,13 @@ impl device::Usb for Device {

// issd_evk3_imx636_start in hal_psee_plugins/include/devices/imx636/imx636_evk3_issd.h {
MipiControl { value: 0x000002f9 }.write(&handle)?;
RoCtrl { value: 0x00000000 }.write(&handle)?;
if configuration.enable_output {
RoCtrl {
area_count_enable: 0,
output_disable: 0,
keep_timer_high: 0,
}.write(&handle)?;
}
match configuration.clock {
Clock::Internal => {
TimeBaseCtrl {
Expand Down Expand Up @@ -746,7 +758,11 @@ impl Drop for Device {
}
.write(&self.handle);
let _ = Unknown002C { value: 0x0022c324 }.write(&self.handle);
let _ = RoCtrl { value: 0x00000002 }.write(&self.handle);
let _ = RoCtrl {
area_count_enable: 0,
output_disable: 1,
keep_timer_high: 0,
}.write(&self.handle);
std::thread::sleep(std::time::Duration::from_millis(1));
let _ = TimeBaseCtrl {
enable: 0,
Expand Down Expand Up @@ -841,6 +857,18 @@ fn update_configuration(
previous_configuration: Option<&Configuration>,
configuration: &Configuration,
) -> Result<(), Error> {
if match previous_configuration {
Some(previous_configuration) => {
previous_configuration.enable_output != configuration.enable_output
}
None => false,
} {
RoCtrl {
area_count_enable: 0,
output_disable: if configuration.enable_output { 0 } else { 1 },
keep_timer_high: 0,
}.write(handle)?;
}
{
let previous_biases = previous_configuration.map(|configuration| &configuration.biases);
update_bias!(pr, BiasPr, handle, previous_biases, configuration.biases);
Expand Down Expand Up @@ -1434,7 +1462,11 @@ register! { TimeBaseCtrl, 0x9008, {
register! { DigCtrl, 0x900C, { value: 0..32 } }
register! { DigStartPos, 0x9010, { value: 0..32 } }
register! { DigEndPos, 0x9014, { value: 0..32 } }
register! { RoCtrl, 0x9028, { value: 0..32 } }
register! { RoCtrl, 0x9028, {
area_count_enable: 0..1,
output_disable: 1..2,
keep_timer_high: 2..3,
} }
register! { AreaX0Addr, 0x902C, { value: 0..32 } }
register! { AreaX1Addr, 0x9030, { value: 0..32 } }
register! { AreaX2Addr, 0x9034, { value: 0..32 } }
Expand Down

0 comments on commit 6702f36

Please sign in to comment.