Fix borrow of packed field
@@ -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());
@@ -76,17 +77,18 @@ impl<T: Io> SerialPort<T>
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]) {
