diff --git a/boards/components/src/bus.rs b/boards/components/src/bus.rs index 8f9f39b5ab..f15882ee15 100644 --- a/boards/components/src/bus.rs +++ b/boards/components/src/bus.rs @@ -62,11 +62,11 @@ macro_rules! spi_bus_component_static { #[macro_export] macro_rules! i2c_master_bus_component_static { - () => {{ + ($I:ty $(,)?) => {{ let address_buffer = kernel::static_buf!([u8; 1]); - let bus = kernel::static_buf!(capsules_extra::bus::I2CMasterBus<'static>); + let bus = kernel::static_buf!(capsules_extra::bus::I2CMasterBus<'static, $I>); let i2c_device = - kernel::static_buf!(capsules_core::virtualizers::virtual_i2c::I2CDevice<'static>); + kernel::static_buf!(capsules_core::virtualizers::virtual_i2c::I2CDevice<'static, $I>); (bus, i2c_device, address_buffer) };}; diff --git a/boards/components/src/graphic_display.rs b/boards/components/src/graphic_display.rs index 9861a9bf67..a0d8fe913c 100644 --- a/boards/components/src/graphic_display.rs +++ b/boards/components/src/graphic_display.rs @@ -26,12 +26,12 @@ //! .finalize(components::graphic_display_component_static!(40960)); //! ``` -use core::mem::MaybeUninit; use capsules_extra::graphic_display::GraphicDisplay; -use kernel::hil::display; +use core::mem::MaybeUninit; use kernel::capabilities; use kernel::component::Component; use kernel::create_capability; +use kernel::hil::display; #[macro_export] macro_rules! graphic_display_component_static { diff --git a/boards/components/src/lib.rs b/boards/components/src/lib.rs index 726d78022b..54ba69802e 100644 --- a/boards/components/src/lib.rs +++ b/boards/components/src/lib.rs @@ -78,8 +78,8 @@ pub mod si7021; pub mod siphash; pub mod sound_pressure; pub mod spi; -pub mod st77xx; pub mod ssd1306; +pub mod st77xx; pub mod temperature; pub mod temperature_rp2040; pub mod temperature_stm; diff --git a/boards/components/src/ssd1306.rs b/boards/components/src/ssd1306.rs index dc13068a9a..ec332ae46d 100644 --- a/boards/components/src/ssd1306.rs +++ b/boards/components/src/ssd1306.rs @@ -1,6 +1,6 @@ -use core::mem::MaybeUninit; use capsules_extra::bus; use capsules_extra::ssd1306; +use core::mem::MaybeUninit; use kernel::component::Component; use kernel::deferred_call::DeferredCall; use kernel::deferred_call::DeferredCallClient; @@ -97,7 +97,7 @@ impl> Component for SSD1306Component { )); self.bus.set_client(ssd1306); - // todo remove ssd1306.initialize_callback_handle(self.deferred_caller.register(ssd1306).unwrap()); + // todo remove ssd1306.initialize_callback_handle(self.deferred_caller.register(ssd1306).unwrap()); ssd1306.register(); ssd1306 diff --git a/boards/nucleo_f429zi/src/main.rs b/boards/nucleo_f429zi/src/main.rs index e70bf11757..96476e2c4d 100644 --- a/boards/nucleo_f429zi/src/main.rs +++ b/boards/nucleo_f429zi/src/main.rs @@ -86,6 +86,7 @@ struct NucleoF429ZI { 'static, stm32f429zi::rtc::Rtc<'static>, >, + display: &'static capsules_extra::graphic_display::GraphicDisplay<'static>, } /// Mapping of integer syscalls to objects that implement syscalls. @@ -638,23 +639,28 @@ pub unsafe fn main() { // I2C SSD1306 screen let i2c_mux = components::i2c::I2CMuxComponent::new(&peripherals.stm32f4.i2c1, None).finalize( - components::i2c_mux_component_static!(stm32f4xx::i2c::I2C<'static>)); - // static_init!( - // MuxI2C<'static, stm32f4xx::i2c::I2C>, - // MuxI2C::new(&peripherals.stm32f4.i2c1, None) - // ); + components::i2c_mux_component_static!(stm32f4xx::i2c::I2C<'static>), + ); kernel::deferred_call::DeferredCallClient::register(i2c_mux); + //todo: bus initialization let bus = components::bus::I2CMasterBusComponent::new( i2c_mux, capsules_extra::ssd1306::SLAVE_ADDRESS_WRITE, ) - .finalize(components::i2c_master_bus_component_static!()); //todo - - let ssd1306_screen = components::ssd1306::SSD1306Component::new(bus) - .finalize(components::ssd1306_component_static!( - capsules_extra::bus::I2CMasterBus<'static, capsules_core::virtualizers::virtual_i2c::I2CDevice<'static, stm32f4xx::i2c::I2C>>, - )); + .finalize(components::i2c_master_bus_component_static!()); + + let ssd1306_screen = components::ssd1306::SSD1306Component::new(bus).finalize( + components::ssd1306_component_static!( + capsules_extra::bus::I2CMasterBus< + 'static, + capsules_core::virtualizers::virtual_i2c::I2CDevice< + 'static, + stm32f4xx::i2c::I2C<'static>, + >, + >, + ), + ); let _ = ssd1306_screen.init(); @@ -702,6 +708,7 @@ pub unsafe fn main() { systick: cortexm4::systick::SysTick::new(), can: can, date_time, + display, }; // // Optional kernel tests diff --git a/capsules/extra/src/lib.rs b/capsules/extra/src/lib.rs index 2117bd99ca..1eab0b122b 100644 --- a/capsules/extra/src/lib.rs +++ b/capsules/extra/src/lib.rs @@ -86,8 +86,8 @@ pub mod sht4x; pub mod si7021; pub mod sip_hash; pub mod sound_pressure; -pub mod st77xx; pub mod ssd1306; +pub mod st77xx; pub mod symmetric_encryption; pub mod temperature; pub mod temperature_rp2040; diff --git a/capsules/extra/src/ssd1306.rs b/capsules/extra/src/ssd1306.rs index 79b588a07b..e5e575b6c2 100644 --- a/capsules/extra/src/ssd1306.rs +++ b/capsules/extra/src/ssd1306.rs @@ -3,16 +3,14 @@ use kernel::{ ErrorCode, }; -use kernel::deferred_call::{ - DeferredCall, DeferredCallClient -}; +use kernel::deferred_call::{DeferredCall, DeferredCallClient}; use crate::bus::{self, Bus, BusWidth}; +use core::cell::Cell; use kernel::hil::display::{ Align, FrameBuffer, FrameBufferClient, FrameBufferSetup, GraphicsFrame, GraphicsMode, PixelFormat, Point, Rotation, Screen, ScreenClient, Tile, }; -use core::cell::Cell; pub const SLAVE_ADDRESS_WRITE: u8 = 0b0111100; pub const SLAVE_ADDRESS_READ: u8 = 0b0111101; diff --git a/kernel/src/hil/display.rs b/kernel/src/hil/display.rs index e803994b0a..e776f7d27f 100644 --- a/kernel/src/hil/display.rs +++ b/kernel/src/hil/display.rs @@ -1,7 +1,7 @@ //! Interface for screens and displays. +use crate::ErrorCode; use core::ops::Add; use core::ops::Sub; -use crate::ErrorCode; pub const MAX_BRIGHTNESS: u16 = 65535;