|
1 | | -.. _blinky-sample: |
2 | | - |
3 | | -Blinky |
| 1 | +i2c demo |
4 | 2 | ###### |
5 | 3 |
|
6 | 4 | Overview |
7 | 5 | ******** |
8 | 6 |
|
9 | | -This Arduino Blinky sample blinks an LED forever using the `ArduinoAPI`. |
| 7 | +This Arduino i2c sample gets data from an ADXL345 sensor connected over `i2c0`. |
10 | 8 |
|
11 | 9 | Requirements |
12 | 10 | ************ |
13 | 11 |
|
14 | 12 | Your board must: |
15 | 13 |
|
16 | | -#. Have an LED connected via a GPIO pin (these are called "User LEDs" on many of |
17 | | - Zephyr's :ref:`boards`). |
18 | | -#. Have the LED configured using the ``led0`` devicetree alias. |
| 14 | +#. Have atleast 1 i2c port. |
| 15 | +#. Have the ADXL345 sensor connected to the I2C port. |
19 | 16 |
|
20 | 17 | Building and Running |
21 | 18 | ******************** |
22 | 19 |
|
23 | 20 | Build and flash Blinky as follows, |
24 | 21 |
|
25 | 22 | ```sh |
26 | | -$> west build -p -b arduino_nano_33_ble samples/basic/arduino-blinky/ -DZEPHYR_EXTRA_MODULES=/home/$USER/zephyrproject/modules/lib/Arduino-Core-Zephyr |
| 23 | +$> west build -p -b arduino_nano_33_ble samples/i2cdemo |
27 | 24 |
|
28 | 25 | $> west flash --bossac=/home/$USER/.arduino15/packages/arduino/tools/bossac/1.9.1-arduino2/bossac |
29 | 26 | ``` |
30 | 27 |
|
31 | | -After flashing, the LED starts to blink. If a runtime error occurs, the sample |
32 | | -exits without printing to the console. |
33 | | - |
34 | | -Adding board support |
35 | | -******************** |
36 | | - |
37 | | -To add support for your board, add something like this to your devicetree: |
38 | | - |
39 | | -.. code-block:: DTS |
40 | | -
|
41 | | - / { |
42 | | - aliases { |
43 | | - led0 = &myled0; |
44 | | - }; |
45 | | -
|
46 | | - leds { |
47 | | - compatible = "gpio-leds"; |
48 | | - myled0: led_0 { |
49 | | - gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; |
50 | | - }; |
51 | | - }; |
52 | | - }; |
53 | | -
|
54 | | -The above sets your board's ``led0`` alias to use pin 13 on GPIO controller |
55 | | -``gpio0``. The pin flags :c:macro:`GPIO_ACTIVE_HIGH` mean the LED is on when |
56 | | -the pin is set to its high state, and off when the pin is in its low state. |
57 | | - |
58 | | -Tips: |
59 | | - |
60 | | -- See :dtcompatible:`gpio-leds` for more information on defining GPIO-based LEDs |
61 | | - in devicetree. |
62 | | - |
63 | | -- If you're not sure what to do, check the devicetrees for supported boards which |
64 | | - use the same SoC as your target. See :ref:`get-devicetree-outputs` for details. |
65 | | - |
66 | | -- See :zephyr_file:`include/zephyr/dt-bindings/gpio/gpio.h` for the flags you can use |
67 | | - in devicetree. |
68 | | - |
69 | | -- If the LED is built in to your board hardware, the alias should be defined in |
70 | | - your :ref:`BOARD.dts file <devicetree-in-out-files>`. Otherwise, you can |
71 | | - define one in a :ref:`devicetree overlay <set-devicetree-overlays>`. |
| 28 | +After flashing, probe the UART pin (TX) and you should be able to see X, Y and Z values if everything goes well. |
0 commit comments