Skip to content

Commit

Permalink
[nrf fromlist] samples: drivers: mbox: allow to configure RX/TX channels
Browse files Browse the repository at this point in the history
By adding Kconfig options for both samples.

Upstream PR: zephyrproject-rtos/zephyr#69303

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
(cherry picked from commit 253593c966f339e7aebbdbbbb8126963f3529ebe)
  • Loading branch information
gmarull authored and carlescufi committed Feb 28, 2024
1 parent 942d10d commit a170171
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
13 changes: 13 additions & 0 deletions samples/drivers/mbox/Kconfig
Expand Up @@ -9,3 +9,16 @@ config INCLUDE_REMOTE_DIR
help
Include remote build header files. Can be used if primary image
needs to be aware of size or base address of secondary image

config TX_CHANNEL_ID
int "Channel ID for TX"
default 1
help
Channel ID for TX


config RX_CHANNEL_ID
int "Channel ID for RX"
default 0
help
Channel ID for RX
17 changes: 17 additions & 0 deletions samples/drivers/mbox/remote/Kconfig
@@ -0,0 +1,17 @@
# Copyright 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

source "Kconfig.zephyr"

config TX_CHANNEL_ID
int "Channel ID for TX"
default 0
help
Channel ID for TX


config RX_CHANNEL_ID
int "Channel ID for RX"
default 1
help
Channel ID for RX
7 changes: 2 additions & 5 deletions samples/drivers/mbox/remote/src/main.c
Expand Up @@ -9,9 +9,6 @@
#include <zephyr/kernel.h>
#include <zephyr/drivers/mbox.h>

#define TX_ID (0)
#define RX_ID (1)

static void callback(const struct device *dev, uint32_t channel,
void *user_data, struct mbox_msg *data)
{
Expand All @@ -28,8 +25,8 @@ int main(void)

dev = DEVICE_DT_GET(DT_NODELABEL(mbox));

mbox_init_channel(&tx_channel, dev, TX_ID);
mbox_init_channel(&rx_channel, dev, RX_ID);
mbox_init_channel(&tx_channel, dev, CONFIG_TX_CHANNEL_ID);
mbox_init_channel(&rx_channel, dev, CONFIG_RX_CHANNEL_ID);

if (mbox_register_callback(&rx_channel, callback, NULL)) {
printk("mbox_register_callback() error\n");
Expand Down
7 changes: 2 additions & 5 deletions samples/drivers/mbox/src/main.c
Expand Up @@ -9,9 +9,6 @@
#include <zephyr/kernel.h>
#include <zephyr/drivers/mbox.h>

#define TX_ID (1)
#define RX_ID (0)

static void callback(const struct device *dev, uint32_t channel,
void *user_data, struct mbox_msg *data)
{
Expand All @@ -28,8 +25,8 @@ int main(void)

dev = DEVICE_DT_GET(DT_NODELABEL(mbox));

mbox_init_channel(&tx_channel, dev, TX_ID);
mbox_init_channel(&rx_channel, dev, RX_ID);
mbox_init_channel(&tx_channel, dev, CONFIG_TX_CHANNEL_ID);
mbox_init_channel(&rx_channel, dev, CONFIG_RX_CHANNEL_ID);

if (mbox_register_callback(&rx_channel, callback, NULL)) {
printk("mbox_register_callback() error\n");
Expand Down

0 comments on commit a170171

Please sign in to comment.