Skip to content

Commit

Permalink
Merge pull request #21 from orukusaki/dma-write-buffer
Browse files Browse the repository at this point in the history
Add impl for embedded_dma::WriteBuffer
  • Loading branch information
bernii authored Jul 14, 2023
2 parents 1aa1ce2 + 48df5b2 commit 641eb5c
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 641eb5c

Please sign in to comment.