samples: Add smbus shell sample application

Add smbus sample for testing SMBus commands.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2022-08-25 09:51:46 +03:00 committed by Anas Nashif
parent 3e0a88e8da
commit cf423b3eaa
7 changed files with 138 additions and 0 deletions

View File

@ -0,0 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.20.0)
if(BOARD STREQUAL qemu_x86_64)
LIST(APPEND QEMU_EXTRA_FLAGS -machine q35)
endif()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(smbus)
target_sources(app PRIVATE src/main.c)

View File

@ -0,0 +1,71 @@
.. _samples_smbus_shell:
SMBus Shell Sample
##################
Overview
********
This is a simple SMBus shell sample that allows arbitrary boards with SMBus
driver supported exploring the SMBus communication with peripheral devices.
Building and Running
********************
This project can be built and executed on as follows:
.. zephyr-app-commands::
:zephyr-app: zephyr/samples/drivers/smbus
:host-os: unix
:board: qemu_x86_64
:goals: run
:compact:
Sample Output
=============
Output from console when application started::
*** Booting Zephyr OS build zephyr-v3.2.0-804-gfedd72615e82 ***
Start SMBUS shell sample qemu_x86_64
uart:~$
List avaibalbe SMBus shell commands with::
uart:~$ smbus
smbus - smbus commands
Subcommands:
quick :SMBus Quick command
Usage: quick <device> <addr>
scan :Scan SMBus peripheral devices command
Usage: scan <device>
byte_read :SMBus: byte read command
Usage: byte_read <device> <addr>
byte_write :SMBus: byte write command
Usage: byte_write <device> <addr> <value>
byte_data_read :SMBus: byte data read command
Usage: byte_data_read <device> <addr> <cmd>
byte_data_write :SMBus: byte data write command
Usage: byte_data_write <device> <addr> <cmd> <value>
word_data_read :SMBus: word data read command
Usage: word_data_read <device> <addr> <cmd>
word_data_write :SMBus: word data write command
Usage: word_data_write <device> <addr> <cmd> <value>
block_write :SMBus: Block Write command
Usage: block_write <device> <addr> <cmd> [<byte1>, ...]
block_read :SMBus: Block Read command
Usage: block_read <device> <addr> <cmd>
Scan for available SMBus devices with command::
uart:~$ smbus scan smbus@fb00
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 51 52 53 54 55 56 57 -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
8 devices found on smbus@fb00

View File

@ -0,0 +1,3 @@
CONFIG_DYNAMIC_INTERRUPTS=y
CONFIG_PCIE=y

View File

@ -0,0 +1,10 @@
CONFIG_SMBUS=y
CONFIG_SMBUS_INTEL_PCH=y
CONFIG_SMBUS_LOG_LEVEL_DBG=y
CONFIG_USERSPACE=y
CONFIG_SHELL=y
CONFIG_LOG=y
CONFIG_EEPROM=y
CONFIG_EEPROM_EMULATOR=n
CONFIG_EEPROM_SIMULATOR=n

View File

@ -0,0 +1,17 @@
/*
* Copyright (c) 2022 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pcie/pcie.h>
&smbus0 {
eeprom2: smbus_eeprom@50 {
compatible = "jedec,smbus-eeprom";
reg = <0x50>;
size = <0x100>;
status = "okay";
};
};

View File

@ -0,0 +1,13 @@
sample:
description: SMBus sample
name: smbus sample
common:
platform_allow: qemu_x86_64 ehl_crb rpl_crb
harness: console
harness_config:
type: one_line
regex:
- "Start SMBUS shell sample"
tests:
sample.drivers.smbus.shell:
tags: smbus

View File

@ -0,0 +1,12 @@
/*
* Copyright (c) 2022 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
void main(void)
{
printk("Start SMBUS shell sample %s\n", CONFIG_BOARD);
}