Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Add support for the ESP32-P4 (#61)
Browse files Browse the repository at this point in the history
* Add support for the ESP32-P4

* Update the CI workflow to check the ESP32-P4
  • Loading branch information
jessebraham authored Dec 22, 2023
1 parent 48514c0 commit 1f628e3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
{ chip: "esp32c3", target: "riscv32imc-unknown-none-elf" },
{ chip: "esp32c6", target: "riscv32imac-unknown-none-elf" },
{ chip: "esp32h2", target: "riscv32imac-unknown-none-elf" },
{ chip: "esp32p4", target: "riscv32imafc-unknown-none-elf" },
]

steps:
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ esp32c2 = []
esp32c3 = []
esp32c6 = []
esp32h2 = []
esp32p4 = []
esp32s2 = []
esp32s3 = []
esp8266 = []

# You must enable exactly 1 of the below features to enable to intended
# communication method (note that "uart" is enabled by default):
uart = []
jtag-serial = ["portable-atomic"] # C3, C6, H2, and S3 only!
jtag-serial = ["portable-atomic"] # C3, C6, H2, P4, and S3 only!
no-op = []

# Enables a `defmt` backend usable with espflash. We force rzcobs encoding to simplify implementation
Expand Down
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fn main() {
cfg!(feature = "esp32c3"),
cfg!(feature = "esp32c6"),
cfg!(feature = "esp32h2"),
cfg!(feature = "esp32p4"),
cfg!(feature = "esp32s2"),
cfg!(feature = "esp32s3"),
cfg!(feature = "esp8266"),
Expand Down Expand Up @@ -33,6 +34,7 @@ fn main() {
&& !(cfg!(feature = "esp32c3")
|| cfg!(feature = "esp32c6")
|| cfg!(feature = "esp32h2")
|| cfg!(feature = "esp32p4")
|| cfg!(feature = "esp32s3"))
{
panic!(
Expand Down
23 changes: 23 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl Printer {
feature = "esp32c3",
feature = "esp32c6",
feature = "esp32h2",
feature = "esp32p4",
feature = "esp32s3"
)
))]
Expand All @@ -106,6 +107,11 @@ mod serial_jtag_printer {
#[cfg(any(feature = "esp32c6", feature = "esp32h2"))]
const SERIAL_JTAG_CONF_REG: usize = 0x6000_F004;

#[cfg(feature = "esp32p4")]
const SERIAL_JTAG_FIFO_REG: usize = 0x500D_2000;
#[cfg(feature = "esp32p4")]
const SERIAL_JTAG_CONF_REG: usize = 0x500D_2004;

#[cfg(feature = "esp32s3")]
const SERIAL_JTAG_FIFO_REG: usize = 0x6003_8000;
#[cfg(feature = "esp32s3")]
Expand Down Expand Up @@ -329,6 +335,23 @@ mod uart_printer {
}
}

#[cfg(feature = "esp32p4")]
impl Functions for Device {
const TX_ONE_CHAR: usize = 0x4FC0_0054;

fn flush() {
unsafe {
const TX_FLUSH: usize = 0x4FC0_0074;
const GET_CHANNEL: usize = 0x4FC0_0038;

let tx_flush: unsafe extern "C" fn(u8) = core::mem::transmute(TX_FLUSH);
let get_channel: unsafe extern "C" fn() -> u8 = core::mem::transmute(GET_CHANNEL);

tx_flush(get_channel());
}
}
}

impl super::Printer {
pub fn write_bytes_assume_cs(&mut self, bytes: &[u8]) {
for chunk in bytes.chunks(Device::CHUNK_SIZE) {
Expand Down

0 comments on commit 1f628e3

Please sign in to comment.