Skip to content
Snippets Groups Projects
Commit 7671e922 authored by Skallwar's avatar Skallwar
Browse files

Fix borrow of packed field

parent b616fdb0
No related branches found
No related tags found
1 merge request!114Fix warnings
......@@ -67,6 +67,7 @@ impl<T: Io> SerialPort<T>
{
pub fn init(&mut self) {
//TODO: Cleanup
unsafe {
self.int_en.write(0x00.into());
self.line_ctrl.write(0x80.into());
self.data.write(0x01.into());
......@@ -75,18 +76,19 @@ impl<T: Io> SerialPort<T>
self.fifo_ctrl.write(0xC7.into());
self.modem_ctrl.write(0x0B.into());
self.int_en.write(0x01.into());
}
}
fn line_sts(&self) -> LineStsFlags {
LineStsFlags::from_bits_truncate(
(self.line_sts.read() & 0xFF.into()).try_into().unwrap_or(0)
(unsafe {self.line_sts.read()} & 0xFF.into()).try_into().unwrap_or(0)
)
}
pub fn receive(&mut self) -> Option<u8> {
if self.line_sts().contains(LineStsFlags::INPUT_FULL) {
Some(
(self.data.read() & 0xFF.into()).try_into().unwrap_or(0)
(unsafe {self.data.read()} & 0xFF.into()).try_into().unwrap_or(0)
)
} else {
None
......@@ -95,7 +97,7 @@ impl<T: Io> SerialPort<T>
pub fn send(&mut self, data: u8) {
while ! self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY) {}
self.data.write(data.into());
unsafe {self.data.write(data.into())}
}
pub fn write(&mut self, buf: &[u8]) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment