mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
refactor reset api for UDMA
there's now unfortunately branch divergence in the NTO/MPW code base The methodology is to code like we're running on NTO, and if the "mpw" feature is selected, we put hacks in to run on MPW hardware. Under the theory that MPW should be totally deprecated once NTO comes out, and therefore the hacks should accumulate in the MPW code base (and ideally be somewhat easy to cull when the time comes).
This commit is contained in:
parent
9c1d3c37c9
commit
a5ebcf5d0f
4 changed files with 33 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ pio-memlcd = []
|
|||
rawserial = []
|
||||
pinger = []
|
||||
swap = []
|
||||
mpw = ["cramium-hal/mpw"]
|
||||
# add this feature to enable pre-emption
|
||||
quantum-timer = ["utralib", "pio"]
|
||||
default = ["app-uart"]
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ pub enum Opcode {
|
|||
/// I2C operations
|
||||
I2c = 9,
|
||||
|
||||
/// Peripheral reset
|
||||
PeriphReset = 10,
|
||||
|
||||
/// Exit server
|
||||
Quit = 255,
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,20 @@ impl UdmaGlobal {
|
|||
)
|
||||
.expect("Couldn't setup UDMA event mapping");
|
||||
}
|
||||
|
||||
pub fn reset(&self, peripheral: PeriphId) {
|
||||
xous::send_message(
|
||||
self.conn,
|
||||
xous::Message::new_blocking_scalar(
|
||||
Opcode::PeriphReset.to_usize().unwrap(),
|
||||
peripheral as u32 as usize,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
)
|
||||
.expect("Couldn't setup UDMA clock");
|
||||
}
|
||||
}
|
||||
|
||||
impl UdmaGlobalConfig for UdmaGlobal {
|
||||
|
|
@ -79,4 +93,6 @@ impl UdmaGlobalConfig for UdmaGlobal {
|
|||
) {
|
||||
self.udma_event_map(peripheral, event_type, to_channel);
|
||||
}
|
||||
|
||||
fn reset(&self, peripheral: PeriphId) { self.reset(peripheral); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,13 @@ fn main() {
|
|||
)
|
||||
};
|
||||
let mut i2c = unsafe {
|
||||
cramium_hal::udma::I2c::new_with_ifram(i2c_channel, 400_000, cram_hal_service::PERCLK, i2c_ifram)
|
||||
cramium_hal::udma::I2c::new_with_ifram(
|
||||
i2c_channel,
|
||||
400_000,
|
||||
cram_hal_service::PERCLK,
|
||||
i2c_ifram,
|
||||
&udma_global,
|
||||
)
|
||||
};
|
||||
|
||||
// -------------------- begin timer workaround code
|
||||
|
|
@ -371,6 +377,12 @@ fn main() {
|
|||
udma_global.map_event_with_offset(periph, event_offset, to_channel);
|
||||
}
|
||||
}
|
||||
Opcode::PeriphReset => {
|
||||
if let Some(scalar) = msg.body.scalar_message() {
|
||||
let periph: PeriphId = num_traits::FromPrimitive::from_usize(scalar.arg1).unwrap();
|
||||
udma_global.reset(periph);
|
||||
}
|
||||
}
|
||||
Opcode::I2c => {
|
||||
let mut buf = unsafe {
|
||||
xous_ipc::Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap())
|
||||
|
|
|
|||
Loading…
Reference in a new issue