Skip to content

Commit

Permalink
samples: boards: nxp: add sample for using SENT driver
Browse files Browse the repository at this point in the history
Add sample for using SENT driver on s32z

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
  • Loading branch information
congnguyenhuu committed Oct 21, 2024
1 parent b45e0a8 commit 6a1a208
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 0 deletions.
8 changes: 8 additions & 0 deletions samples/boards/nxp/s32/sent/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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(sent)

target_sources(app PRIVATE src/main.c)
28 changes: 28 additions & 0 deletions samples/boards/nxp/s32/sent/boards/s32z2xxdc2_s32z270_rtu0.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/

&pinctrl {
sent_1_default: sent_1_default {
group1 {
pinmux = <PK2_SENT_1_CH1_I>;
input-enable;
};
};
};

&sent_1 {
pinctrl-0 = <&sent_1_default>;
pinctrl-names = "default";
status = "okay";
};

&sent_1_ch1 {
num-data-nibbles = <8>;
tick-time-prescaler-us = <3>;
bus-timeout-cycles = <256>;
calib-method-low-latency;
status = "okay";
};
28 changes: 28 additions & 0 deletions samples/boards/nxp/s32/sent/boards/s32z2xxdc2_s32z270_rtu1.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/

&pinctrl {
sent_1_default: sent_1_default {
group1 {
pinmux = <PK2_SENT_1_CH1_I>;
input-enable;
};
};
};

&sent_1 {
pinctrl-0 = <&sent_1_default>;
pinctrl-names = "default";
status = "okay";
};

&sent_1_ch1 {
num-data-nibbles = <8>;
tick-time-prescaler-us = <3>;
bus-timeout-cycles = <256>;
calib-method-low-latency;
status = "okay";
};
4 changes: 4 additions & 0 deletions samples/boards/nxp/s32/sent/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG_SENT=y
CONFIG_SENT_LOG_LEVEL_DBG=y
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
14 changes: 14 additions & 0 deletions samples/boards/nxp/s32/sent/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sample:
description: Sample for using SENT driver
name: NXP S32 SENT sample

tests:
sample.boards.nxp_s32.sent:
platform_allow:
- s32z2xxdc2/s32z270/rtu0
- s32z2xxdc2/s32z270/rtu1
- s32z2xxdc2@D/s32z270/rtu0
- s32z2xxdc2@D/s32z270/rtu1
depends_on: sent
tags: sent
harness: console
31 changes: 31 additions & 0 deletions samples/boards/nxp/s32/sent/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(nxp_s32_sent_sample, LOG_LEVEL_DBG);

#include <zephyr/kernel.h>

#include <zephyr/drivers/sent/sent.h>

#define SENT_NODE DT_INST(0, nxp_s32_sent_controller)

void rx_cb(const struct device *dev, uint8_t channel_id, struct sent_frame *frame,
enum sent_state state, void *user_data)
{
LOG_INF("rx ch %d", channel_id);
}

int main(void)
{
const struct device *const dev = DEVICE_DT_GET(SENT_NODE);

sent_add_rx_callback(dev, 1, rx_cb, NULL);

sent_start(dev, 1);

return 0;
}

0 comments on commit 6a1a208

Please sign in to comment.