Compare commits
5 Commits
cdac9c3e5d
...
ac594a3d1f
| Author | SHA1 | Date | |
|---|---|---|---|
| ac594a3d1f | |||
| 9f9f674abb | |||
| 1b653fd31a | |||
| 9354f54b4d | |||
| ba2b25393c |
Generated
+502
-129
File diff suppressed because it is too large
Load Diff
+17
-17
@@ -9,25 +9,25 @@ name = "padmapper"
|
||||
path = "./src/bin/main.rs"
|
||||
|
||||
[dependencies]
|
||||
esp-hal = { version = "~1.0", features = ["defmt", "esp32s3", "unstable"] }
|
||||
|
||||
esp-rtos = { version = "0.2.0", features = [
|
||||
"defmt",
|
||||
"embassy",
|
||||
"esp-alloc",
|
||||
"esp32s3",
|
||||
] }
|
||||
|
||||
defmt = "1.1.0"
|
||||
esp-bootloader-esp-idf = { version = "0.4.0", features = ["defmt", "esp32s3"] }
|
||||
|
||||
embassy-executor = { version = "0.9.1", features = ["defmt"] }
|
||||
embassy-time = { version = "0.5.0", features = ["defmt"] }
|
||||
esp-alloc = { version = "0.9.0", features = ["defmt"] }
|
||||
esp-println = { version = "0.17.0", features = ["colors", "defmt-espflash", "esp32s3", "uart"], default-features = false }
|
||||
|
||||
critical-section = "1.2.0"
|
||||
defmt = "1.1.0"
|
||||
static_cell = "2.1.1"
|
||||
|
||||
embassy-executor = { version = "0.10.0", features = ["defmt"] }
|
||||
embassy-time = { version = "0.5.0", features = ["defmt"] }
|
||||
embassy-usb = { version = "0.6.0", features = ["defmt"] }
|
||||
usbd-hid = "0.10.0"
|
||||
|
||||
esp-alloc = { version = "0.10.0", features = ["defmt", "esp32s3"] }
|
||||
esp-bootloader-esp-idf = { version = "0.5.0", features = ["defmt", "esp32s3"] }
|
||||
esp-hal = { version = "~1.1", features = ["defmt", "esp32s3", "unstable"] }
|
||||
esp-println = { version = "0.17.0", features = ["colors",
|
||||
"defmt-espflash",
|
||||
"esp32s3",
|
||||
"uart"], default-features = false
|
||||
}
|
||||
esp-rtos = { version = "0.3.0", features = ["defmt", "embassy", "esp-alloc", "esp32s3"] }
|
||||
|
||||
ws2812-rs = "0.3.1"
|
||||
|
||||
|
||||
|
||||
+39
-13
@@ -10,12 +10,16 @@
|
||||
use defmt::info;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::Timer;
|
||||
use embassy_usb::{Builder, Config as UsbConfig};
|
||||
use esp_hal::Blocking;
|
||||
use esp_hal::clock::CpuClock;
|
||||
use esp_hal::interrupt::software::SoftwareInterruptControl;
|
||||
use esp_hal::otg_fs::{asynch::{Driver as UsbDriver, Config as UsbDriverConfig}, Usb};
|
||||
use esp_hal::spi::master::{Spi, Config as SpiConfig};
|
||||
use esp_hal::time::Rate;
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use esp_println::println;
|
||||
#[allow(unused_imports)] use esp_println; // Needed to link global logger
|
||||
use static_cell::StaticCell;
|
||||
use ws2812_rs::{WS2812SPI, SendColorBySPI, Color};
|
||||
|
||||
#[panic_handler]
|
||||
@@ -31,30 +35,57 @@ esp_bootloader_esp_idf::esp_app_desc!();
|
||||
|
||||
const LED_SPI_HZ: u32 = 3_200_000;
|
||||
|
||||
const VENDOR_ID: u16 = 0x2341;
|
||||
const PRODUCT_ID: u16 = 0x8037;
|
||||
const MANUFACTURER_NAME: &str = "Padmapper";
|
||||
const PRODUCT_NAME: &str = "StepManiaX"; // AI suggests "StepManiaX Stage" or "StepManiaX Controller"
|
||||
|
||||
static EP_STATE: StaticCell<[u8; 1024]> = StaticCell::new();
|
||||
static CONFIG_DESCRIPTOR: StaticCell<[u8; 256]> = StaticCell::new();
|
||||
static BOS_DESCRIPTOR: StaticCell<[u8; 256]> = StaticCell::new(); // Do I actually need this?
|
||||
static CONTROL_BUF: StaticCell<[u8; 64]> = StaticCell::new();
|
||||
|
||||
#[allow(
|
||||
clippy::large_stack_frames,
|
||||
reason = "it's not unusual to allocate larger buffers etc. in main"
|
||||
)]
|
||||
#[esp_rtos::main]
|
||||
async fn main(spawner: Spawner) -> ! {
|
||||
// generator version: 1.2.0
|
||||
|
||||
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
||||
let peripherals = esp_hal::init(config);
|
||||
|
||||
esp_alloc::heap_allocator!(#[esp_hal::ram(reclaimed)] size: 73744);
|
||||
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
esp_rtos::start(timg0.timer0);
|
||||
let software_interrupt = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
|
||||
esp_rtos::start(timg0.timer0, software_interrupt.software_interrupt0);
|
||||
|
||||
let spi = Spi::new(peripherals.SPI2,
|
||||
SpiConfig::default().with_frequency(Rate::from_hz(LED_SPI_HZ)))
|
||||
.unwrap()
|
||||
.with_mosi(peripherals.GPIO48);
|
||||
let led = WS2812SPI::new(spi);
|
||||
spawner.spawn(heartbeat_task(led)).unwrap();
|
||||
spawner.spawn(heartbeat_task(led).unwrap());
|
||||
|
||||
spawner.spawn(logging_task()).unwrap();
|
||||
let usb_dev = Usb::new(peripherals.USB0,
|
||||
peripherals.GPIO20, // USB D+
|
||||
peripherals.GPIO19); // USB D-
|
||||
let usb_driver = UsbDriver::new(usb_dev,
|
||||
EP_STATE.init([0; 1024]),
|
||||
UsbDriverConfig::default());
|
||||
|
||||
let mut usb_config = UsbConfig::new(VENDOR_ID, PRODUCT_ID);
|
||||
usb_config.manufacturer = Some(MANUFACTURER_NAME);
|
||||
usb_config.product = Some(PRODUCT_NAME);
|
||||
let usb_builder = Builder::new(usb_driver,
|
||||
usb_config,
|
||||
CONFIG_DESCRIPTOR.init([0; 256]),
|
||||
BOS_DESCRIPTOR.init([0; 256]), // Don't think I need this?
|
||||
&mut [], // no msos descriptors
|
||||
CONTROL_BUF.init([0; 64]));
|
||||
|
||||
let usb = usb_builder.build();
|
||||
spawner.spawn(usb_task(usb).unwrap());
|
||||
|
||||
info!("Padmapper initialized!");
|
||||
|
||||
@@ -82,11 +113,6 @@ async fn heartbeat_task(mut led: WS2812SPI<Spi<'static, Blocking>>) {
|
||||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn logging_task() {
|
||||
let mut i = 0u64;
|
||||
loop {
|
||||
info!("Hello from Padmapper! {}\r\n", i);
|
||||
Timer::after_secs(1).await;
|
||||
i += 1;
|
||||
}
|
||||
async fn usb_task(mut usb: embassy_usb::UsbDevice<'static, UsbDriver<'static>>) {
|
||||
usb.run().await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user