I have a PCT2075 temp sensor that I am communicating with over I2C and works fine in a simple program. Now I'm trying to implement this functionality from a user level function. User mode will not have access to GPIO, so I figure that I would implement a system call to call a read(). I'm not sure of the design pattern for this functionality. I figure this needs to be a static mut, but Im having trouble with it.
let dr = DeviceResources::take().unwrap();
let p = dr.peripherals;
let pins = dr.pins;
// Configure clocks
let clocks = hifive1::clock::configure(
p.PRCI,
p.AONCLK,
320.mhz().into()
);
// Configure UART for stdout
hifive1::stdout::configure(
p.UART0,
pin!(pins, uart0_tx),
pin!(pins, uart0_rx),
115_200.bps(),
clocks,
);
// Configure I2C
let sda = pin!(pins, i2c0_sda).into_iof0();
let scl = pin!(pins, i2c0_scl).into_iof0();
let mut i2c = I2c::new(p.I2C0, sda, scl, Speed::Normal, clocks);