samples: boards: espressif: ulp: Add interrupt sample
Add an interrupt triggered by HP Core sample Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
This commit is contained in:
parent
243f7c44d3
commit
5a338ff5bb
@ -0,0 +1,13 @@
|
||||
# Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(REMOTE_ZEPHYR_DIR ${CMAKE_CURRENT_BINARY_DIR}/../interrupt_ulp_lpcore/zephyr)
|
||||
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
message(STATUS "${CONFIG_BOARD_TARGET} compile as Master in this sample")
|
||||
project(interrupt_ulp_hpcore)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
source "share/sysbuild/Kconfig"
|
||||
|
||||
config ULP_REMOTE_BOARD
|
||||
string
|
||||
default "esp32c6_devkitc/esp32c6/lpcore" if $(BOARD) = "esp32c6_devkitc"
|
||||
@ -0,0 +1,53 @@
|
||||
.. zephyr:code-sample:: interrupt-ulp
|
||||
:name: Interrupt ULP
|
||||
|
||||
HP Core interrupt LP Core.
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
This sample shows how to trigger LP Core interrupt from the HP core.
|
||||
|
||||
Building and Flashing
|
||||
*********************
|
||||
|
||||
Build the sample code as follows:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/boards/espressif/ulp/lp_core/interrupt_ulp
|
||||
:board: esp32c6_devkitc/esp32c6/hpcore
|
||||
:west-args: --sysbuild
|
||||
:goals: build
|
||||
:compact:
|
||||
|
||||
Flash it to the device with the command:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/boards/espressif/ulp/lp_core/interrupt_ulp
|
||||
:board: esp32c6_devkitc/esp32c6/hpcore
|
||||
:west-args: --sysbuild
|
||||
:goals: flash
|
||||
:compact:
|
||||
|
||||
Sample Output
|
||||
=============
|
||||
|
||||
Console output on the HP core:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
Triggering ULP interrupt...
|
||||
Triggering ULP interrupt...
|
||||
Triggering ULP interrupt...
|
||||
Triggering ULP interrupt...
|
||||
Triggering ULP interrupt...
|
||||
|
||||
Console output on the LP core:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
LP PMU interrupt received: 0
|
||||
LP PMU interrupt received: 1
|
||||
LP PMU interrupt received: 2
|
||||
LP PMU interrupt received: 3
|
||||
LP PMU interrupt received: 4
|
||||
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
&lp_uart {
|
||||
status = "okay";
|
||||
};
|
||||
@ -0,0 +1 @@
|
||||
CONFIG_ULP_COPROC_ENABLED=y
|
||||
@ -0,0 +1,11 @@
|
||||
# Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
message(STATUS "${BOARD} compiles as remote in this sample")
|
||||
project(interrupt_ulp_lpcore)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
@ -0,0 +1 @@
|
||||
# nothing here
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ulp_lp_core_utils.h"
|
||||
#include "ulp_lp_core_interrupts.h"
|
||||
|
||||
volatile uint32_t lp_core_pmu_intr_count;
|
||||
|
||||
void ulp_lp_core_lp_pmu_intr_handler(void)
|
||||
{
|
||||
ulp_lp_core_sw_intr_clear();
|
||||
lp_core_pmu_intr_count++;
|
||||
printf("LP PMU interrupt received: %d\n", lp_core_pmu_intr_count);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lp_core_pmu_intr_count = 0;
|
||||
ulp_lp_core_intr_enable();
|
||||
ulp_lp_core_sw_intr_enable(true);
|
||||
|
||||
while (1) {
|
||||
/* Wait forever, handling interrupts */
|
||||
asm volatile("wfi");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
sample:
|
||||
name: ESP32-C6 LP_CORE Interrupt Sample
|
||||
tests:
|
||||
sample.boards.espressif.ulp.lp_core.interrupt_ulp:
|
||||
platform_allow:
|
||||
- esp32c6_devkitc/esp32c6/hpcore
|
||||
tags:
|
||||
- samples
|
||||
sysbuild: true
|
||||
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ulp_lp_core.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
while (1) {
|
||||
printf("Triggering ULP interrupt...\n");
|
||||
ulp_lp_core_sw_intr_trigger();
|
||||
k_sleep(K_MSEC(1000));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Copyright 2024 Espressif
|
||||
|
||||
# Add external project
|
||||
ExternalZephyrProject_Add(
|
||||
APPLICATION interrupt_ulp_lpcore
|
||||
SOURCE_DIR ${APP_DIR}/remote
|
||||
BOARD ${SB_CONFIG_ULP_REMOTE_BOARD}
|
||||
)
|
||||
|
||||
# Add dependencies so that the remote sample will be built first
|
||||
# This is required because some primary cores need information from the
|
||||
# remote core's build, such as the output image's LMA
|
||||
add_dependencies(interrupt_ulp interrupt_ulp_lpcore)
|
||||
sysbuild_add_dependencies(CONFIGURE interrupt_ulp interrupt_ulp_lpcore)
|
||||
sysbuild_add_dependencies(FLASH interrupt_ulp_lpcore interrupt_ulp)
|
||||
|
||||
if(SB_CONFIG_BOOTLOADER_MCUBOOT)
|
||||
# Make sure MCUboot is flashed first
|
||||
sysbuild_add_dependencies(FLASH interrupt_ulp mcuboot)
|
||||
endif()
|
||||
Loading…
Reference in New Issue
Block a user