From 7c9a87aea26728aab27aaffbb7713b00ecf3b080 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Wed, 8 Jan 2020 17:36:20 -0500 Subject: [PATCH] samples: remove i2c scanner Now part of the I2C shell and works for all boards. Signed-off-by: Anas Nashif --- samples/drivers/i2c_scanner/CMakeLists.txt | 8 --- samples/drivers/i2c_scanner/README.rst | 26 -------- .../drivers/i2c_scanner/overlay-nrf52.conf | 2 - samples/drivers/i2c_scanner/prj.conf | 2 - samples/drivers/i2c_scanner/sample.yaml | 13 ---- samples/drivers/i2c_scanner/src/main.c | 64 ------------------- 6 files changed, 115 deletions(-) delete mode 100644 samples/drivers/i2c_scanner/CMakeLists.txt delete mode 100644 samples/drivers/i2c_scanner/README.rst delete mode 100644 samples/drivers/i2c_scanner/overlay-nrf52.conf delete mode 100644 samples/drivers/i2c_scanner/prj.conf delete mode 100644 samples/drivers/i2c_scanner/sample.yaml delete mode 100644 samples/drivers/i2c_scanner/src/main.c diff --git a/samples/drivers/i2c_scanner/CMakeLists.txt b/samples/drivers/i2c_scanner/CMakeLists.txt deleted file mode 100644 index 905a71e2f2a..00000000000 --- a/samples/drivers/i2c_scanner/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.13.1) -include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) -project(i2c_scanner) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/drivers/i2c_scanner/README.rst b/samples/drivers/i2c_scanner/README.rst deleted file mode 100644 index d1431ae7216..00000000000 --- a/samples/drivers/i2c_scanner/README.rst +++ /dev/null @@ -1,26 +0,0 @@ -.. _i2c_scanner: - -I2C Scanner sample -################## - -Overview -******** -This sample sends I2C messages without any data (i.e. stop condition -after sending just the address). If there is an ACK for the -address, it prints the address as ``FOUND``. - -.. warning:: As there is no standard I2C detection command, this sample - uses arbitrary SMBus commands (namely SMBus quick write and SMBus - receive byte) to probe for devices. This sample program can confuse - your I2C bus, cause data loss, and is known to corrupt - the Atmel AT24RF08 EEPROM found on many IBM Thinkpad laptops. - See also the `i2cdetect man page - `_ - -Building and Running -******************** -.. zephyr-app-commands:: - :zephyr-app: samples/drivers/i2c_scanner - :board: nrf52840_blip - :conf: "prj.conf overlay-nrf52.conf" - :goals: build flash diff --git a/samples/drivers/i2c_scanner/overlay-nrf52.conf b/samples/drivers/i2c_scanner/overlay-nrf52.conf deleted file mode 100644 index 822d475140f..00000000000 --- a/samples/drivers/i2c_scanner/overlay-nrf52.conf +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG_I2C_NRFX=y -CONFIG_I2C_0=y diff --git a/samples/drivers/i2c_scanner/prj.conf b/samples/drivers/i2c_scanner/prj.conf deleted file mode 100644 index cc1b04cdb7d..00000000000 --- a/samples/drivers/i2c_scanner/prj.conf +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG_PRINTK=y -CONFIG_I2C=y diff --git a/samples/drivers/i2c_scanner/sample.yaml b/samples/drivers/i2c_scanner/sample.yaml deleted file mode 100644 index 05d1b0ea239..00000000000 --- a/samples/drivers/i2c_scanner/sample.yaml +++ /dev/null @@ -1,13 +0,0 @@ -sample: - name: I2C scanner -tests: - sample.drivers.i2c_scanner: - platform_whitelist: nrf52840_blip nrf51_ble400 - tags: drivers - depends_on: i2c - harness: console - harness_config: - type: one_line - regex: - - "0x50 FOUND" - fixture: fixture_i2c_FRAM diff --git a/samples/drivers/i2c_scanner/src/main.c b/samples/drivers/i2c_scanner/src/main.c deleted file mode 100644 index 9e4d3cc86b4..00000000000 --- a/samples/drivers/i2c_scanner/src/main.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2018 Tavish Naruka - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include -#include - -#ifdef ARDUINO_I2C_LABEL -#define I2C_DEV ARDUINO_I2C_LABEL -#else -#define I2C_DEV "I2C_0" -#endif - -/** - * @file This app scans I2C bus for any devices present - */ - -void main(void) -{ - struct device *i2c_dev; - u8_t cnt = 0, first = 0x04, last = 0x77; - - printk("Starting i2c scanner...\n\n"); - - i2c_dev = device_get_binding(I2C_DEV); - if (!i2c_dev) { - printk("I2C: Device driver %s not found.\n", I2C_DEV); - return; - } - - printk(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n"); - for (u8_t i = 0; i <= last; i += 16) { - printk("%02x: ", i); - for (u8_t j = 0; j < 16; j++) { - if (i + j < first || i + j > last) { - printk(" "); - continue; - } - - struct i2c_msg msgs[1]; - u8_t dst; - - /* Send the address to read from */ - msgs[0].buf = &dst; - msgs[0].len = 0U; - msgs[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP; - if (i2c_transfer(i2c_dev, &msgs[0], 1, i + j) == 0) { - printk("%02x ", i + j); - ++cnt; - } else { - printk("-- "); - } - } - printk("\n"); - } - - printk("\n%u devices found on %s\n", cnt, I2C_DEV); - -}