#![no_std]
pub mod commands;
pub mod config;
pub mod display_list;
pub mod graphics;
pub mod interface;
pub mod low_level;
pub mod memory;
pub mod models;
mod error;
pub use error::CoprocessorError;
pub use error::Error;
pub use evegfx_macros::eve_format as format;
pub(crate) use low_level::{host_commands, registers};
#[doc(inline)]
pub use models::bt815::BT815;
use interface::Interface;
#[doc(inline)]
pub type BT816 = BT815;
use models::Model;
pub struct EVE<M: Model, I: Interface> {
pub(crate) ll: low_level::LowLevel<M, I>,
}
impl<M: Model, I: Interface> EVE<M, I> {
#[allow(unused_variables)]
pub fn new(m: M, ei: I) -> Self {
Self::new_internal(ei)
}
pub(crate) fn new_internal(ei: I) -> Self {
Self {
ll: low_level::LowLevel::new(ei),
}
}
pub fn take_interface(self) -> I {
self.ll.take_interface()
}
pub fn borrow_interface<'a>(&'a mut self) -> &'a mut I {
self.ll.borrow_interface()
}
pub fn take_low_level(self) -> low_level::LowLevel<M, I> {
self.ll
}
pub fn borrow_low_level<'a>(&'a mut self) -> &'a mut low_level::LowLevel<M, I> {
&mut self.ll
}
pub fn start_system_clock(
&mut self,
source: config::ClockSource,
video: &config::VideoTimings,
) -> Result<(), Error<I>> {
config::activate_system_clock(self, source, video)
}
pub fn poll_for_boot(&mut self, poll_limit: u32) -> Result<bool, Error<I>> {
config::poll_for_boot(self, poll_limit)
}
pub fn configure_video_pins(
&mut self,
mode: &config::RGBElectricalMode,
) -> Result<(), Error<I>> {
config::configure_video_pins(self, mode)
}
pub fn start_video(&mut self, c: &config::VideoTimings) -> Result<(), Error<I>> {
config::activate_pixel_clock(self, c)
}
pub fn new_display_list<
F: FnOnce(
&mut display_list::JustBuilder<low_level::LowLevel<M, I>>,
) -> Result<(), error::Error<I>>,
>(
&mut self,
f: F,
) -> Result<(), error::Error<I>> {
self.ll.dl_reset();
{
let mut builder = display_list::just_builder(&mut self.ll);
f(&mut builder)?;
}
let dlswap_ptr = M::reg_ptr(registers::Register::DLSWAP);
self.ll.wr8(dlswap_ptr, 0b00000010)
}
pub fn coprocessor<W: commands::waiter::Waiter<M, I>>(
self,
waiter: W,
) -> commands::Result<commands::Coprocessor<M, I, W>, M, I, W> {
let ei = self.ll.take_interface();
commands::Coprocessor::new(ei, waiter)
}
pub fn coprocessor_polling(
self,
) -> commands::Result<
commands::Coprocessor<M, I, commands::waiter::PollingWaiter<M, I>>,
M,
I,
commands::waiter::PollingWaiter<M, I>,
> {
let ei = self.ll.take_interface();
commands::Coprocessor::new_polling(ei)
}
}