It compiles!

This commit is contained in:
Sebastian H. Gabrielli 2024-12-20 17:47:22 +01:00
parent 691a5f24ac
commit 7a7ce13365
2 changed files with 42 additions and 11 deletions

View File

@ -23,6 +23,7 @@ embassy-sync = { version = "0.6" }
embassy-time = { version = "0.3", features = ["defmt", "defmt-timestamp-uptime"] }
#embassy-net-nrf91 = { version = "0.1.0", features = ["defmt"] }
embassy-net = { version = "0.5.0", features = ["defmt", "tcp", "proto-ipv4", "medium-ip"] }
embassy-embedded-hal = "0.2"
cortex-m = { version = "0.7.6", features = ["critical-section-single-core", "inline-asm"] }
embassy-nrf = { version = "0.2", features = ["defmt", "nrf9160-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
@ -35,4 +36,4 @@ ili9341 = "0.6.0"
display-interface-spi = "0.5.0"
[profile.release]
debug = 2
debug = 2

View File

@ -1,18 +1,30 @@
#![no_std]
#![no_main]
use core::cell::RefCell;
use defmt::info;
use display_interface_spi::SPIInterface;
use embassy_embedded_hal::shared_bus::blocking::spi::SpiDevice;
use embassy_executor::Spawner;
use embassy_nrf::{bind_interrupts, gpio::{Level, Output, OutputDrive}, peripherals, spim};
use embassy_nrf::{
bind_interrupts,
gpio::{Level, Output, OutputDrive},
peripherals,
spim::{self, Spim},
};
use embassy_sync::blocking_mutex::Mutex;
use embassy_time::Timer;
use ili9341::Ili9341;
use {defmt_rtt as _, panic_probe as _};
use defmt::info;
use embedded_graphics::{
mono_font::{ascii::FONT_6X10, MonoTextStyle}, pixelcolor::{BinaryColor, Rgb565}, prelude::*, primitives::{
mono_font::{ascii::FONT_6X10, MonoTextStyle},
pixelcolor::{BinaryColor, Rgb565},
prelude::*,
primitives::{
Circle, PrimitiveStyle, PrimitiveStyleBuilder, Rectangle, StrokeAlignment, Triangle,
}, text::{Alignment, Text}
},
text::{Alignment, Text},
};
// Setup interrupts
@ -35,19 +47,37 @@ async fn main(_spawner: Spawner) {
let mut spim_config = spim::Config::default();
spim_config.frequency = spim::Frequency::M8;
// Create a new SPI interface on the nrf
let spi = embassy_nrf::spim::Spim::new(p.SERIAL3, Irqs, sck, miso, mosi, spim_config);
///////////////////////////////////////////
// Create a new SPI interface on the nrf //
///////////////////////////////////////////
// Setup the chip select as an output pin
let chip_select = Output::new(cs_pin, Level::Low, OutputDrive::Standard);
// Grab the SPI Master mode peripheral form the nRF60
let spim = embassy_nrf::spim::Spim::new(p.SERIAL3, Irqs, sck, miso, mosi, spim_config);
// Use the SPI peripheral to create a shared bus
let spi_bus: Mutex<embassy_sync::blocking_mutex::raw::NoopRawMutex, _> =
Mutex::new(RefCell::new(spim));
// Use the shared bus to create a SPI Device to use for the display
let spi_display = SpiDevice::new(&spi_bus, chip_select);
// Create a new SPI display interface
let direction_control = Output::new(p.P0_07, Level::High, OutputDrive::Standard);
let chip_select = Output::new(p.P0_08, Level::Low, OutputDrive::Standard);
let iface = SPIInterface::new(spi, direction_control);
let iface = SPIInterface::new(spi_display, direction_control);
// Create a new display
let display_reset = Output::new(p.P0_12, Level::High, OutputDrive::Standard);
let display_orientation = ili9341::Orientation::Landscape;
let display_size = ili9341::DisplaySize240x320;
let mut display = Ili9341::new(iface, display_reset, &mut embassy_time::Delay, display_orientation, display_size).unwrap();
let mut display = Ili9341::new(
iface,
display_reset,
&mut embassy_time::Delay,
display_orientation,
display_size,
)
.unwrap();
display.clear(Rgb565::RED).unwrap();
@ -109,4 +139,4 @@ async fn main(_spawner: Spawner) {
led.set_low();
Timer::after_millis(300).await;
}
}
}