samples: remove i2c scanner
Now part of the I2C shell and works for all boards. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
53e12e8a11
commit
7c9a87aea2
6 changed files with 0 additions and 115 deletions
|
@ -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})
|
|
@ -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
|
||||
<http://manpages.ubuntu.com/manpages/bionic/man8/i2cdetect.8.html>`_
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/drivers/i2c_scanner
|
||||
:board: nrf52840_blip
|
||||
:conf: "prj.conf overlay-nrf52.conf"
|
||||
:goals: build flash
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_I2C_NRFX=y
|
||||
CONFIG_I2C_0=y
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_PRINTK=y
|
||||
CONFIG_I2C=y
|
|
@ -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
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Tavish Naruka <tavishnaruka@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <zephyr.h>
|
||||
#include <sys/printk.h>
|
||||
#include <device.h>
|
||||
#include <drivers/i2c.h>
|
||||
|
||||
#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);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue