diff --git a/boards/arm/lpcxpresso54114_m0/doc/lpcxpresso54114_m0.rst b/boards/arm/lpcxpresso54114_m0/doc/lpcxpresso54114_m0.rst index 288e1b44b9c..9535e954688 100644 --- a/boards/arm/lpcxpresso54114_m0/doc/lpcxpresso54114_m0.rst +++ b/boards/arm/lpcxpresso54114_m0/doc/lpcxpresso54114_m0.rst @@ -32,7 +32,7 @@ Debugging ========= You can debug an application in the usual way. Here is an example for the -:ref:`ipm_mcux` application. +:ref:`ipm-mcux-sample` application. .. zephyr-app-commands:: :zephyr-app: samples/subsys/ipc/ipm_mcux @@ -52,7 +52,7 @@ serial port: .. code-block:: console - ***** BOOTING ZEPHYR OS v1.10.99 - BUILD: Feb 7 2018 20:32:27 ***** + ***** Booting Zephyr OS v1.11.0-764-g4e3007a ***** Hello World from MASTER! arm Received: 1 ... diff --git a/samples/subsys/ipc/ipc.rst b/samples/subsys/ipc/ipc.rst new file mode 100644 index 00000000000..c75a201fd3e --- /dev/null +++ b/samples/subsys/ipc/ipc.rst @@ -0,0 +1,10 @@ +.. _ipc_samples: + +IPC Samples +########### + +.. toctree:: + :maxdepth: 1 + :glob: + + **/* diff --git a/samples/subsys/ipc/ipm_mcux/CMakeLists.txt b/samples/subsys/ipc/ipm_mcux/CMakeLists.txt new file mode 100644 index 00000000000..6e092e3afa8 --- /dev/null +++ b/samples/subsys/ipc/ipm_mcux/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright (c) 2017, NXP +# +# SPDX-License-Identifier: Apache-2.0 +# +set(BOARD lpcxpresso54114_m4) + + +include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) +include(ExternalProject) + +ExternalProject_Add( + ipm_mcux_remote + SOURCE_DIR ${APPLICATION_SOURCE_DIR}/remote + INSTALL_COMMAND "" # This particular build system has no install command +) + +project(NONE) + +target_sources(app PRIVATE src/main_master.c) +add_dependencies(core_m0_inc_target ipm_mcux_remote) diff --git a/samples/subsys/ipc/ipm_mcux/README.rst b/samples/subsys/ipc/ipm_mcux/README.rst new file mode 100644 index 00000000000..57ec3abc72b --- /dev/null +++ b/samples/subsys/ipc/ipm_mcux/README.rst @@ -0,0 +1,43 @@ +.. _ipm-mcux-sample: + +Sample mailbox application +########################## + +Overview +******** + +The :ref:`lpcxpresso54114` board has two core processors (Cortex-M4F +and Cortex-M0+). This sample application uses a mailbox to send messages +from one processor core to the other. + +Requirements +************ + +- :ref:`lpcxpresso54114` board + +Building and Running +******************** + +.. zephyr-app-commands:: + :zephyr-app: samples/subsys/ipc/ipm_mcux + :board: lpcxpresso54114_m4 + :goals: debug + +Open a serial terminal (minicom, putty, etc.) and connect the board with the +following settings: + +- Speed: 115200 +- Data: 8 bits +- Parity: None +- Stop bits: 1 + +Reset the board and the following message will appear on the corresponding +serial port: + +.. code-block:: console + + ***** Booting Zephyr OS v1.11.0-764-g4e3007a ***** + Hello World from MASTER! arm + Received: 1 + ... + Received: 99 diff --git a/samples/subsys/ipc/ipm_mcux/prj.conf b/samples/subsys/ipc/ipm_mcux/prj.conf new file mode 100644 index 00000000000..d7ca2178be3 --- /dev/null +++ b/samples/subsys/ipc/ipm_mcux/prj.conf @@ -0,0 +1,7 @@ +CONFIG_PRINTK=y +CONFIG_IPM=y +CONFIG_IPM_MCUX=y +CONFIG_SLAVE_CORE_MCUX=y +CONFIG_SLAVE_IMAGE_MCUX="${ZEPHYR_BINARY_DIR}/../ipm_mcux_remote-prefix/src/ipm_mcux_remote-build/zephyr/zephyr.bin" +CONFIG_TIMESLICE_SIZE=1 +CONFIG_MAIN_STACK_SIZE=2048 diff --git a/samples/subsys/ipc/ipm_mcux/remote/CMakeLists.txt b/samples/subsys/ipc/ipm_mcux/remote/CMakeLists.txt new file mode 100644 index 00000000000..e1cb05a736b --- /dev/null +++ b/samples/subsys/ipc/ipm_mcux/remote/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2017, NXP +# +# SPDX-License-Identifier: Apache-2.0 +# +set(BOARD lpcxpresso54114_m0) + +include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) +project(NONE) + +target_sources(app PRIVATE src/main_remote.c) diff --git a/samples/subsys/ipc/ipm_mcux/remote/prj.conf b/samples/subsys/ipc/ipm_mcux/remote/prj.conf new file mode 100644 index 00000000000..5be3728281b --- /dev/null +++ b/samples/subsys/ipc/ipm_mcux/remote/prj.conf @@ -0,0 +1,5 @@ +CONFIG_STDOUT_CONSOLE=n +CONFIG_PRINTK=n +CONFIG_IPM=y +CONFIG_IPM_MCUX=y +CONFIG_PLATFORM_SPECIFIC_INIT=n diff --git a/samples/subsys/ipc/ipm_mcux/remote/src/main_remote.c b/samples/subsys/ipc/ipm_mcux/remote/src/main_remote.c new file mode 100644 index 00000000000..c26ef57f852 --- /dev/null +++ b/samples/subsys/ipc/ipm_mcux/remote/src/main_remote.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018, NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +struct device *ipm; + +void ping_ipm_callback(void *context, u32_t id, volatile void *data) +{ + ipm_send(ipm, 1, 0, (const void *)data, 4); +} + + + +void main(void) +{ + ipm = device_get_binding(MAILBOX_0_LABEL); + if (!ipm) { + while (1) { + } + } + ipm_register_callback(ipm, ping_ipm_callback, NULL); + ipm_set_enabled(ipm, 1); + while (1) { + } +} diff --git a/samples/subsys/ipc/ipm_mcux/sample.yaml b/samples/subsys/ipc/ipm_mcux/sample.yaml new file mode 100644 index 00000000000..7a9a5b67b37 --- /dev/null +++ b/samples/subsys/ipc/ipm_mcux/sample.yaml @@ -0,0 +1,8 @@ +sample: + description: Sample app that sends messages between the two cores on + the lpcxpresso54114 using a mailbox. + name: IPM MCUX Mailbox Sample +tests: + test: + platform_whitelist: lpcxpresso54114_m4 + tags: samples ipm diff --git a/samples/subsys/ipc/ipm_mcux/src/main_master.c b/samples/subsys/ipc/ipm_mcux/src/main_master.c new file mode 100644 index 00000000000..945506f2142 --- /dev/null +++ b/samples/subsys/ipc/ipm_mcux/src/main_master.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018, NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +struct device *ipm; +int gcounter; + +void ping_ipm_callback(void *context, u32_t id, volatile void *data) +{ + gcounter = *(int *)data; + /* Show current ping-pong counter value */ + printk("Received: %d\n", gcounter); + /* Increment on our side */ + gcounter++; + if (gcounter < 100) { + /* Send back to the other core */ + ipm_send(ipm, 1, 0, &gcounter, 4); + } +} + +void main(void) +{ + int first_message = 1; /* do not start from 0, + * zero value can't be sent via mailbox register + */ + printk("Hello World from MASTER! %s\n", CONFIG_ARCH); + + /* Get IPM device handle */ + ipm = device_get_binding(MAILBOX_0_LABEL); + if (!ipm) { + printk("Could not get IPM device handle!\n"); + while (1) { + } + } + + /* Register application callback with no context */ + ipm_register_callback(ipm, ping_ipm_callback, NULL); + /* Enable the IPM device */ + ipm_set_enabled(ipm, 1); + + /* Send initial message with 4 bytes length*/ + ipm_send(ipm, 1, 0, &first_message, 4); + while (1) { + } +}