diff --git a/samples/boards/nxp/s32/psi5/CMakeLists.txt b/samples/boards/nxp/s32/psi5/CMakeLists.txt new file mode 100644 index 000000000000..cc19ea188af9 --- /dev/null +++ b/samples/boards/nxp/s32/psi5/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(psi5) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/boards/nxp/s32/psi5/boards/s32z2xxdc2_s32z270_rtu0.overlay b/samples/boards/nxp/s32/psi5/boards/s32z2xxdc2_s32z270_rtu0.overlay new file mode 100644 index 000000000000..ce6ed4e0edf7 --- /dev/null +++ b/samples/boards/nxp/s32/psi5/boards/s32z2xxdc2_s32z270_rtu0.overlay @@ -0,0 +1,52 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + psi5_0_default: psi5_0_default { + group1 { + pinmux = , ; + output-enable; + }; + group2 { + pinmux = , ; + input-enable; + }; + }; +}; + +&psi5_0 { + pinctrl-0 = <&psi5_0_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&psi5_0_ch1 { + target-pulse-us = <8>; + decoder-offset-us = <0>; + low-pulse-width-us = <4>; + high-pulse-width-us = <4>; + tx-mode = "short-frame-31"; + rx-buf-size = <32>; + bitrate-kbps = <125>; + array-slot-duration-us = <1000 1000>; + array-slot-start-offset-us = <0 0>; + array-slot-data-length = <16 16>; + status = "okay"; +}; + +&psi5_0_ch2 { + target-pulse-us = <8>; + decoder-offset-us = <0>; + low-pulse-width-us = <4>; + high-pulse-width-us = <4>; + tx-mode = "short-frame-31"; + rx-buf-size = <32>; + bitrate-kbps = <125>; + array-slot-duration-us = <1000 1000>; + array-slot-start-offset-us = <0 0>; + array-slot-data-length = <16 16>; + status = "okay"; +}; diff --git a/samples/boards/nxp/s32/psi5/boards/s32z2xxdc2_s32z270_rtu1.overlay b/samples/boards/nxp/s32/psi5/boards/s32z2xxdc2_s32z270_rtu1.overlay new file mode 100644 index 000000000000..ce6ed4e0edf7 --- /dev/null +++ b/samples/boards/nxp/s32/psi5/boards/s32z2xxdc2_s32z270_rtu1.overlay @@ -0,0 +1,52 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + psi5_0_default: psi5_0_default { + group1 { + pinmux = , ; + output-enable; + }; + group2 { + pinmux = , ; + input-enable; + }; + }; +}; + +&psi5_0 { + pinctrl-0 = <&psi5_0_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&psi5_0_ch1 { + target-pulse-us = <8>; + decoder-offset-us = <0>; + low-pulse-width-us = <4>; + high-pulse-width-us = <4>; + tx-mode = "short-frame-31"; + rx-buf-size = <32>; + bitrate-kbps = <125>; + array-slot-duration-us = <1000 1000>; + array-slot-start-offset-us = <0 0>; + array-slot-data-length = <16 16>; + status = "okay"; +}; + +&psi5_0_ch2 { + target-pulse-us = <8>; + decoder-offset-us = <0>; + low-pulse-width-us = <4>; + high-pulse-width-us = <4>; + tx-mode = "short-frame-31"; + rx-buf-size = <32>; + bitrate-kbps = <125>; + array-slot-duration-us = <1000 1000>; + array-slot-start-offset-us = <0 0>; + array-slot-data-length = <16 16>; + status = "okay"; +}; diff --git a/samples/boards/nxp/s32/psi5/prj.conf b/samples/boards/nxp/s32/psi5/prj.conf new file mode 100644 index 000000000000..bac255b3c705 --- /dev/null +++ b/samples/boards/nxp/s32/psi5/prj.conf @@ -0,0 +1,3 @@ +CONFIG_PSI5=y +CONFIG_PSI5_LOG_LEVEL_DBG=y +CONFIG_LOG=y diff --git a/samples/boards/nxp/s32/psi5/sample.yaml b/samples/boards/nxp/s32/psi5/sample.yaml new file mode 100644 index 000000000000..81ac63c0b838 --- /dev/null +++ b/samples/boards/nxp/s32/psi5/sample.yaml @@ -0,0 +1,14 @@ +sample: + description: Sample for using PSI5 driver + name: NXP S32 PSI5 sample + +tests: + sample.boards.nxp_s32.psi5: + platform_allow: + - s32z2xxdc2/s32z270/rtu0 + - s32z2xxdc2/s32z270/rtu1 + - s32z2xxdc2@D/s32z270/rtu0 + - s32z2xxdc2@D/s32z270/rtu1 + depends_on: psi5 + tags: psi5 + harness: console diff --git a/samples/boards/nxp/s32/psi5/src/main.c b/samples/boards/nxp/s32/psi5/src/main.c new file mode 100644 index 000000000000..6fc2a4172bcf --- /dev/null +++ b/samples/boards/nxp/s32/psi5/src/main.c @@ -0,0 +1,43 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +LOG_MODULE_REGISTER(nxp_s32_psi5_sample, LOG_LEVEL_DBG); + +#include + +#include + +#define PSI5_NODE DT_INST(0, nxp_s32_psi5) + +void tx_cb(const struct device *dev, uint8_t channel_id, enum psi5_state state, void *user_data) +{ + LOG_INF("tx ch %d", channel_id); +} + +void rx_cb(const struct device *dev, uint8_t channel_id, struct psi5_frame *frame, + enum psi5_state state, void *user_data) +{ + LOG_INF("rx ch %d", channel_id); +} + +int main(void) +{ + const struct device *const dev = DEVICE_DT_GET(PSI5_NODE); + uint64_t send_data = 0x123456789ABCDEF; + + psi5_add_rx_callback(dev, 2, rx_cb, NULL); + + psi5_start(dev, 1); + + psi5_send(dev, 1, send_data, K_MSEC(100), tx_cb, NULL); + + psi5_stop(dev, 1); + + k_sleep(K_MSEC(100)); + + return 0; +}