Skip to content

Commit

Permalink
allocate large swathes of memory to camera
Browse files Browse the repository at this point in the history
this is for higher resolution QR code scanning

makes it incompatible with simultaneous USB usage

however, when camera is off, the USB stack can be started, and
vice-versa. Basically, you can't both do active USB and camera
at the same time, but you can do one or the other.
  • Loading branch information
bunnie committed Oct 20, 2024
1 parent 86dd350 commit 9e0bd64
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions libs/cramium-hal/src/board/baosec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ pub const SPIM_FLASH_IFRAM_ADDR: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IF
// one page for the I2C driver
pub const I2C_IFRAM_ADDR: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 8 * 4096;

// memory for camera driver
pub const CAM_IFRAM_LEN_PAGES: usize = 10;
// memory for camera driver - note this is mutually exclusive with USB, can't use both at the same time
pub const CAM_IFRAM_LEN_PAGES: usize = 30;
pub const CAM_IFRAM_ADDR: usize =
utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - (9 + CAM_IFRAM_LEN_PAGES) * 4096;
utralib::HW_IFRAM1_MEM + utralib::HW_IFRAM1_MEM_LEN - CAM_IFRAM_LEN_PAGES * 4096;

// USB pages - USB subsystem is a hog, needs a lot of pages
pub const CRG_IFRAM_PAGES: usize = 22;
// USB pages - USB subsystem is a hog, needs a lot of pages, note this is mutually exclusive with camera,
// can't use both at once
pub const CRG_IFRAM_PAGES: usize = 23; // +1 for extended application buffer by 4k
pub const CRG_UDC_MEMBASE: usize =
utralib::HW_IFRAM1_MEM + utralib::HW_IFRAM1_MEM_LEN - CRG_IFRAM_PAGES * 0x1000;

// MANUALLY SYNCED TO ALLOCATIONS ABOVE
// inclusive numbering - we allocate pages from the top-down, so the last number should generally be 31
pub const IFRAM0_RESERVED_PAGE_RANGE: [usize; 2] = [31 - (9 + CAM_IFRAM_LEN_PAGES), 31];
pub const IFRAM1_RESERVED_PAGE_RANGE: [usize; 2] = [31 - CRG_IFRAM_PAGES, 31];
pub const IFRAM0_RESERVED_PAGE_RANGE: [usize; 2] = [31 - 9, 31];
pub const IFRAM1_RESERVED_PAGE_RANGE: [usize; 2] = [31 - CAM_IFRAM_LEN_PAGES, 31];

/// Setup pins for the baosec display
/// Returns a spi channel object and descriptor for the C/D + CS pins as a (port, c/d pin, cs pin) tuple
Expand Down

0 comments on commit 9e0bd64

Please sign in to comment.