mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix event setting API
This commit is contained in:
parent
c448fc2f2e
commit
2145145595
1 changed files with 11 additions and 13 deletions
|
|
@ -3,10 +3,7 @@ use arbitrary_int::Number;
|
||||||
use bao1x_api::IoxHal;
|
use bao1x_api::IoxHal;
|
||||||
use bao1x_api::{bio::*, bio_code};
|
use bao1x_api::{bio::*, bio_code};
|
||||||
use utra::bio_bdma;
|
use utra::bio_bdma;
|
||||||
use utralib::{
|
use utralib::{utra::bio_bdma::*, *};
|
||||||
utra::bio_bdma::{SFR_ELEVEL_FIFO_EVENT_LEVEL0, SFR_IRQMASK_0},
|
|
||||||
*,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
use crate::iox::Iox;
|
use crate::iox::Iox;
|
||||||
|
|
@ -624,15 +621,16 @@ impl<'a> BioApi<'a> for BioSharedState {
|
||||||
|
|
||||||
fn setup_fifo_event_triggers(&mut self, config: FifoEventConfig) -> Result<(), BioError> {
|
fn setup_fifo_event_triggers(&mut self, config: FifoEventConfig) -> Result<(), BioError> {
|
||||||
let event_offset = config.which.to_usize_checked() * 2 + config.trigger_slot.raw_value() as usize;
|
let event_offset = config.which.to_usize_checked() * 2 + config.trigger_slot.raw_value() as usize;
|
||||||
assert!(event_offset <= 7, "Computed event offset is invalid");
|
match event_offset {
|
||||||
// safety: this is safe because which is bounds checked with to_usize_checked() and the
|
0 => self.bio.rmwf(SFR_ELEVEL_FIFO_EVENT_LEVEL0, config.level.level().as_u32()),
|
||||||
// implementation of arbitrary_int that encodes trigger_slot is also bounds checked. The assert
|
1 => self.bio.rmwf(SFR_ELEVEL_FIFO_EVENT_LEVEL1, config.level.level().as_u32()),
|
||||||
// above also helps confirm a lack of logic bugs.
|
2 => self.bio.rmwf(SFR_ELEVEL_FIFO_EVENT_LEVEL2, config.level.level().as_u32()),
|
||||||
unsafe {
|
3 => self.bio.rmwf(SFR_ELEVEL_FIFO_EVENT_LEVEL3, config.level.level().as_u32()),
|
||||||
self.bio
|
4 => self.bio.rmwf(SFR_ELEVEL_FIFO_EVENT_LEVEL4, config.level.level().as_u32()),
|
||||||
.base()
|
5 => self.bio.rmwf(SFR_ELEVEL_FIFO_EVENT_LEVEL5, config.level.level().as_u32()),
|
||||||
.add(SFR_ELEVEL_FIFO_EVENT_LEVEL0.offset() + event_offset)
|
6 => self.bio.rmwf(SFR_ELEVEL_FIFO_EVENT_LEVEL6, config.level.level().as_u32()),
|
||||||
.write_volatile(config.level.level().as_u32());
|
7 => self.bio.rmwf(SFR_ELEVEL_FIFO_EVENT_LEVEL7, config.level.level().as_u32()),
|
||||||
|
_ => unimplemented!("Computed event offset is invalid"),
|
||||||
}
|
}
|
||||||
let mask = 1u32 << event_offset as u32;
|
let mask = 1u32 << event_offset as u32;
|
||||||
let mut lt_gt_eq_set = 0u32;
|
let mut lt_gt_eq_set = 0u32;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue