Skip to content

Commit

Permalink
add impl for embedded_dma::WriteBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
orukusaki committed Jul 6, 2023
1 parent 1aa1ce2 commit 48df5b2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
//! ```

#![no_std]
use embedded_dma::ReadBuffer;
use embedded_dma::{ReadBuffer, WriteBuffer};
use embedded_graphics::{
draw_target::DrawTarget,
geometry::OriginDimensions,
Expand Down Expand Up @@ -281,6 +281,20 @@ unsafe impl<C: PixelColor, B: DMACapableFrameBufferBackend<Color = C>> ReadBuffe
}
}

unsafe impl<C: PixelColor, B: DMACapableFrameBufferBackend<Color = C>> WriteBuffer
for FrameBuf<C, B>
{
type Word = u8;
unsafe fn write_buffer(&mut self) -> (*mut Self::Word, usize) {
(
(self.data.data_ptr() as *mut Self::Word),
self.height
* self.width
* (core::mem::size_of::<C>() / core::mem::size_of::<Self::Word>()),
)
}
}

#[cfg(test)]
mod tests {
extern crate std;
Expand Down

0 comments on commit 48df5b2

Please sign in to comment.