Skip to content

Commit

Permalink
SPI RAM patch
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfFan committed Jan 19, 2024
1 parent c448680 commit ff963dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion esp-hal-common/src/soc/esp32s3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub unsafe fn configure_cpu_caches() {
}

// ideally these should be configurable
const CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE: u32 = 0x4000; // ESP32S3_INSTRUCTION_CACHE_16KB
const CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE: u32 = 0x8000; // ESP32S3_INSTRUCTION_CACHE_16KB
const CONFIG_ESP32S3_ICACHE_ASSOCIATED_WAYS: u8 = 8; // ESP32S3_INSTRUCTION_CACHE_8WAYS
const CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_SIZE: u8 = 32; // ESP32S3_INSTRUCTION_CACHE_LINE_32B

Expand Down
5 changes: 5 additions & 0 deletions esp-hal-common/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use core::marker::PhantomData;

use fugit::HertzU32;
use procmacros::ram;

use super::{
DuplexMode,
Expand Down Expand Up @@ -2526,6 +2527,7 @@ pub trait Instance {
/// you must ensure that the whole messages was written correctly, use
/// [`Self::flush`].
// FIXME: See below.
#[ram]
fn write_bytes(&mut self, words: &[u8]) -> Result<(), Error> {
let num_chunks = words.len() / FIFO_SIZE;

Expand Down Expand Up @@ -2586,6 +2588,7 @@ pub trait Instance {
/// Sends out a stuffing byte for every byte to read. This function doesn't
/// perform flushing. If you want to read the response to something you
/// have written before, consider using [`Self::transfer`] instead.
#[ram]
fn read_bytes(&mut self, words: &mut [u8]) -> Result<(), Error> {
let empty_array = [EMPTY_WRITE_PAD; FIFO_SIZE];

Expand All @@ -2606,6 +2609,7 @@ pub trait Instance {
// FIXME: Using something like `core::slice::from_raw_parts` and
// `copy_from_slice` on the receive registers works only for the esp32 and
// esp32c3 varaints. The reason for this is unknown.
#[ram]
fn read_bytes_from_fifo(&mut self, words: &mut [u8]) -> Result<(), Error> {
let reg_block = self.register_block();

Expand Down Expand Up @@ -2642,6 +2646,7 @@ pub trait Instance {
Ok(())
}

#[ram]
fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Error> {
for chunk in words.chunks_mut(FIFO_SIZE) {
self.write_bytes(chunk)?;
Expand Down

0 comments on commit ff963dc

Please sign in to comment.