start to lay in foundations for USB integration

This commit is contained in:
bunnie 2024-06-01 13:35:31 +08:00
parent 97110cd231
commit e415fd44e7
5 changed files with 40 additions and 3 deletions

View file

@ -94,5 +94,6 @@ quantum-timer-test = ["pio", "pio-proc"]
spim-test = []
spi-alt-channel = []
irq-test = []
usb-test = []
resume = [] # suspend/resume pathway code
default = ["board-bringup", "irq-test"]
default = ["board-bringup", "usb-test"]

View file

@ -4,3 +4,5 @@ pub use cramium::*;
pub mod swap;
#[cfg(feature = "swap")]
pub use swap::*;
#[cfg(feature = "usb-test")]
pub mod usb_test;

View file

@ -634,6 +634,11 @@ pub fn early_init() {
}
}
#[cfg(feature = "usb-test")]
{
crate::platform::usb_test::usb_test();
}
udma_uart.write("Press any key to continue...".as_bytes());
getc();
crate::println!("\n\rBooting!\n\r");

View file

@ -86,12 +86,12 @@ SECTIONS
. = ALIGN(4);
_edata = .;
} > REGION_DATA AT > REGION_RODATA
/*
.fonts : ALIGN(65536)
{
KEEP(*(.fontdata));
} > FONTS
*/
.bss (NOLOAD) :
{
_sbss = .;

View file

@ -0,0 +1,29 @@
use corigine_usb::CORIGINE_USB_BASE;
pub fn usb_test() {
let mut csr = utralib::CSR::new(CORIGINE_USB_BASE as *mut u32);
crate::println!("devcap: {:x}", csr.r(corigine_usb::DEVCAP));
crate::println!("max speed: {:x}", csr.rf(corigine_usb::DEVCONFIG_MAX_SPEED));
crate::println!("usb3 disable: {:x}", csr.rf(corigine_usb::DEVCONFIG_USB3_DISABLE_COUNT));
}
#[allow(dead_code)]
pub mod corigine_usb {
use utralib::{Field, Register};
pub const DEVCAP: Register = Register::new(0, 0xffffffff);
pub const DEVCAP_VESION: Field = Field::new(8, 0, DEVCAP);
pub const DEVCAP_EP_IN: Field = Field::new(4, 8, DEVCAP);
pub const DEVCAP_EP_OUT: Field = Field::new(4, 12, DEVCAP);
pub const DEVCAP_MAX_INTS: Field = Field::new(10, 16, DEVCAP);
pub const DEVCAP_GEN1: Field = Field::new(1, 27, DEVCAP);
pub const DEVCAP_GEN2: Field = Field::new(1, 28, DEVCAP);
pub const DEVCAP_ISOCH: Field = Field::new(1, 29, DEVCAP);
pub const DEVCONFIG: Register = Register::new(0x10 / 4, 0xFF);
pub const DEVCONFIG_MAX_SPEED: Field = Field::new(4, 0, DEVCONFIG);
pub const DEVCONFIG_USB3_DISABLE_COUNT: Field = Field::new(4, 4, DEVCONFIG);
pub const CORIGINE_USB_BASE: usize = 0x5020_2400;
}