Fix borrow of packed field
This commit is contained in:
@@ -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]) {
|
||||
|
||||
Reference in New Issue
Block a user