zephyrproject-rtos / gsoc-2022-arduino-core

Arduino Core Zephyr Module (GSoC 2022 Project)
Apache License 2.0
44 stars 11 forks source link

I2c support #34

Closed DhruvaG2000 closed 2 years ago

DhruvaG2000 commented 2 years ago

@szczys I have tested the code from here: https://www.engineersgarage.com/adxl345-accelerometer-arduino-i2c/

It is simple and plain thus making easier to debug and implement.

DhruvaG2000 commented 2 years ago

Builds successfully:

└─❯ git status
On branch i2c-support
Your branch is up to date with 'origin/i2c-support'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .cache/
        build/
        cores/arduino/api

nothing added to commit but untracked files present (use "git add" to track)

┌───────────────────took 18ms
│.../gsoc-2022-arduino-core on  i2c-support [$?]
└─❯ west build -p -b arduino_nano_33_ble_sense samples/i2cdemo     -DZEPHYR_EXTRA_MODULES=/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core
-- west build: making build dir /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/samples/i2cdemo
-- Found Python3: /usr/bin/python3.10 (found suitable exact version "3.10.4") found components: Interpreter
-- Cache files will be written to: /home/dhruva/.cache/zephyr
-- Zephyr version: 3.1.99 (/home/dhruva/zephyrproject/zephyr)
-- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
-- Board: arduino_nano_33_ble_sense
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.14.2 (/home/dhruva/zephyr-sdk-0.14.2)
-- Found dtc: /home/dhruva/zephyr-sdk-0.14.2/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
-- Found toolchain: zephyr 0.14.2 (/home/dhruva/zephyr-sdk-0.14.2)
-- Found BOARD.dts: /home/dhruva/zephyrproject/zephyr/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble_sense.dts
-- Found devicetree overlay: /home/dhruva/zephyrproject/zephyr/../modules/lib/Arduino-Zephyr-API/variants/arduino_nano_33_ble_sense/arduino_nano_33_ble_sense.overlay
-- Generated zephyr.dts: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/dts.cmake
Parsing /home/dhruva/zephyrproject/zephyr/Kconfig
Loaded configuration '/home/dhruva/zephyrproject/zephyr/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble_sense_defconfig'
Merged configuration '/home/dhruva/zephyrproject/zephyr/../modules/lib/Arduino-Zephyr-API/module.conf'
Configuration saved to '/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/.config'
Kconfig header saved to '/home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/dhruva/zephyr-sdk-0.14.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dhruva/zephyrproject/modules/lib/gsoc-2022-arduino-core/build
-- west build: building application
[1/163] Preparing syscall dependency handling

[3/163] Generating include/generated/version.h
-- Zephyr version: 3.1.99 (/home/dhruva/zephyrproject/zephyr), build: zephyr-v3.1.0-3166-g0b6f4c7537ba
[153/163] Linking CXX executable zephyr/zephyr_pre0.elf

[157/163] Linking CXX executable zephyr/zephyr_pre1.elf

[163/163] Linking CXX executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       44260 B       928 KB      4.66%
            SRAM:        5696 B       256 KB      2.17%
        IDT_LIST:          0 GB         2 KB      0.00%
DhruvaG2000 commented 2 years ago

Runs okay on ADXL345 (included i2cdemo) as well: image

DhruvaG2000 commented 2 years ago

Also tested with very minimal changes with an external library (https://github.com/Seeed-Studio/Accelerometer_ADXL345), and it seems we still have to implement a few more SErial wrappers, but otherwise I2C seems completely functional (it builds, and runs!)\

image