-
Couldn't load subscription status.
- Fork 1.4k
add mbox backend for eGPIO #16592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
carlescufi
merged 7 commits into
nrfconnect:main
from
jaz1-nordic:add-struct-communication-to-egpio
Oct 3, 2024
Merged
add mbox backend for eGPIO #16592
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e50e75d
manifest: update sdk-zephyr with changes for eGPIO blinky
jaz1-nordic 1a9538b
applications: sdp: Change naming convention from SWDIOD to SDP
jaz1-nordic 4d7592d
drivers: gpio: add mbox backend for eGPIO
jaz1-nordic 9615800
applications: sdp: add mbox backend for eGPIO
jaz1-nordic dbc826b
snippets: add mbox option for egpio snippet
jaz1-nordic 722c094
sysbuild: Add SDP FLPR image to automatic sysbuilds
jaz1-nordic cb2dc7e
samples: basic: blinky: add eGPIO tests configuration
jaz1-nordic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
applications/sdp/gpio/boards/nrf54l15dk_nrf54l15_cpuflpr_icmsg.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Copyright (c) 2024 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| / { | ||
| ipc { | ||
| ipc0: ipc0 { | ||
| compatible = "zephyr,ipc-icmsg"; | ||
| tx-region = <&sram_tx>; | ||
| rx-region = <&sram_rx>; | ||
| mboxes = <&cpuflpr_vevif_rx 21>, <&cpuflpr_vevif_tx 20>; | ||
| mbox-names = "rx", "tx"; | ||
| status = "okay"; | ||
| }; | ||
| }; | ||
| }; |
13 changes: 13 additions & 0 deletions
13
applications/sdp/gpio/boards/nrf54l15dk_nrf54l15_cpuflpr_mbox.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /* | ||
| * Copyright (c) 2024 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| / { | ||
| mbox_consumer: mbox_consumer { | ||
| compatible = "vnd,mbox-consumer"; | ||
| mboxes = <&cpuflpr_vevif_rx 21>, <&cpuflpr_vevif_tx 20>; | ||
| mbox-names = "rx", "tx"; | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| * Copyright (c) 2024 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| #ifndef MAIN_H__ | ||
| #define MAIN_H__ | ||
|
|
||
| #include <zephyr/kernel.h> | ||
| #include <drivers/gpio/nrfe_gpio.h> | ||
|
|
||
| #if !defined(CONFIG_GPIO_NRFE_EGPIO_BACKEND_ICMSG) && !defined(CONFIG_GPIO_NRFE_EGPIO_BACKEND_MBOX) | ||
jaz1-nordic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #error "Define communication backend type" | ||
| #endif | ||
|
|
||
| void process_packet(nrfe_gpio_data_packet_t *packet); | ||
| int backend_init(void); | ||
|
|
||
| #endif /* MAIN_H__ */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CONFIG_MBOX=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| sample: | ||
| name: eGPIO application | ||
| description: SW-defined GPIO application | ||
| common: | ||
| integration_platforms: | ||
| - nrf54l15dk/nrf54l15/cpuflpr | ||
| tests: | ||
| applications.sdp.egpio_mbox: | ||
| build_only: true | ||
| sysbuild: true | ||
| platform_allow: nrf54l15dk/nrf54l15/cpuflpr | ||
| tags: ci_build sysbuild gpio | ||
| extra_args: | ||
| EXTRA_DTC_OVERLAY_FILE="./boards/nrf54l15dk_nrf54l15_cpuflpr_mbox.overlay" | ||
| extra_configs: | ||
| - CONFIG_GPIO_NRFE_EGPIO_BACKEND_MBOX=y | ||
|
|
||
| applications.sdp.egpio_icmsg: | ||
| build_only: true | ||
| sysbuild: true | ||
| platform_allow: nrf54l15dk/nrf54l15/cpuflpr | ||
| tags: ci_build sysbuild gpio | ||
| extra_args: | ||
| EXTRA_DTC_OVERLAY_FILE="./boards/nrf54l15dk_nrf54l15_cpuflpr_icmsg.overlay" | ||
| extra_configs: | ||
| - CONFIG_GPIO_NRFE_EGPIO_BACKEND_ICMSG=y | ||
| - CONFIG_IPC_SERVICE=y | ||
| - CONFIG_IPC_SERVICE_BACKEND_ICMSG=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Copyright (c) 2024 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| #include "../include/main.h" | ||
| #include <zephyr/ipc/ipc_service.h> | ||
|
|
||
| static struct ipc_ept ep; | ||
|
|
||
| volatile uint32_t bound_sem = 1; | ||
|
|
||
| static void ep_bound(void *priv) | ||
| { | ||
| bound_sem = 0; | ||
| } | ||
|
|
||
| static void ep_recv(const void *data, size_t len, void *priv) | ||
| { | ||
| (void)len; | ||
| (void)priv; | ||
|
|
||
| process_packet((nrfe_gpio_data_packet_t *)data); | ||
| } | ||
|
|
||
| static struct ipc_ept_cfg ep_cfg = { | ||
| .cb = { | ||
| .bound = ep_bound, | ||
| .received = ep_recv, | ||
| }, | ||
| }; | ||
|
|
||
| int backend_init(void) | ||
| { | ||
| int ret = 0; | ||
| const struct device *ipc0_instance; | ||
| volatile uint32_t delay = 0; | ||
|
|
||
| #if !defined(CONFIG_SYS_CLOCK_EXISTS) | ||
| /* Wait a little bit for IPC service to be ready on APP side */ | ||
| while (delay < 1000) { | ||
| delay++; | ||
| } | ||
| #endif | ||
|
|
||
| ipc0_instance = DEVICE_DT_GET(DT_NODELABEL(ipc0)); | ||
|
|
||
| ret = ipc_service_open_instance(ipc0_instance); | ||
| if ((ret < 0) && (ret != -EALREADY)) { | ||
| return ret; | ||
| } | ||
|
|
||
| ret = ipc_service_register_endpoint(ipc0_instance, &ep, &ep_cfg); | ||
| if (ret < 0) { | ||
| return ret; | ||
| } | ||
|
|
||
| /* Wait for endpoint to be bound */ | ||
| while (bound_sem != 0) { | ||
| }; | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Copyright (c) 2024 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| #include "../include/main.h" | ||
| #include <zephyr/drivers/mbox.h> | ||
|
|
||
| static const struct mbox_dt_spec rx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx); | ||
|
|
||
| /** | ||
| * @brief Callback function for when a message is received from the mailbox | ||
| * @param instance Pointer to the mailbox device instance | ||
| * @param channel Unused, but required by the mailbox API | ||
| * @param user_data Pointer to the received message | ||
| * @param msg_data Unused, but required by the mailbox API | ||
| * | ||
| * This function is called when a message is received from the mailbox. | ||
| * It is responsible for handling the received data and logging any errors. | ||
| */ | ||
| static void mbox_callback(const struct device *instance, uint32_t channel, void *user_data, | ||
| struct mbox_msg *msg_data) | ||
| { | ||
| /* Unused parameters */ | ||
| (void)msg_data; | ||
|
|
||
| /* Check for invalid arguments */ | ||
| if (user_data == NULL) { | ||
| return; | ||
| } | ||
|
|
||
| nrfe_gpio_mbox_data_t *rx_data = (nrfe_gpio_mbox_data_t *)user_data; | ||
|
|
||
| /* Try and get lock for the shared data structure */ | ||
| if (atomic_flag_test_and_set(&rx_data->lock.locked)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use zephyr's atomic_set_bit with zephyr's primitve |
||
| /* Return in case lock is not acquired (used by other core)*/ | ||
| return; | ||
| } | ||
|
|
||
| nrfe_gpio_data_packet_t *packet = (nrfe_gpio_data_packet_t *)&rx_data->data; | ||
|
|
||
| process_packet(packet); | ||
|
|
||
| /* Clear shared_data.buffer_size (there is no more data available) | ||
| * This is necessary so that the other core knows that the data has been read | ||
| */ | ||
| rx_data->lock.data_size = 0; | ||
|
|
||
| /* We are finished with the shared data structure, so we can release the lock */ | ||
| atomic_flag_clear(&rx_data->lock.locked); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Initialize the mailbox driver. | ||
| * | ||
| * This function sets up the mailbox receive channel with the callback | ||
| * function specified in the DT node. | ||
| * | ||
| * @return 0 on success, negative error code on failure. | ||
| */ | ||
| static int mbox_init(void *shared_data) | ||
| { | ||
| int ret; | ||
|
|
||
| /* Register the callback function for the mailbox receive channel */ | ||
| ret = mbox_register_callback_dt(&rx_channel, mbox_callback, shared_data); | ||
| if (ret < 0) { | ||
| return ret; | ||
| } | ||
|
|
||
| /* Enable the mailbox receive channel */ | ||
| return mbox_set_enabled_dt(&rx_channel, true); | ||
| } | ||
|
|
||
| int backend_init(void) | ||
| { | ||
| int ret = 0; | ||
|
|
||
| static nrfe_gpio_mbox_data_t *rx_data = | ||
| (nrfe_gpio_mbox_data_t *)((uint8_t *)(DT_REG_ADDR(DT_NODELABEL(sram_rx)))); | ||
|
|
||
| ret = mbox_init((void *)rx_data); | ||
| if (ret < 0) { | ||
| return ret; | ||
| } | ||
|
|
||
| /* clear the buffer locks and their size holders */ | ||
| atomic_flag_clear(&rx_data->lock.locked); | ||
| rx_data->lock.data_size = 0; | ||
|
|
||
| return 0; | ||
| } | ||
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.