Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,28 @@ jobs:
path: Arduino-Zephyr-API

- name: Initialize
working-directory: Arduino-Zephyr-API
run: |
west init -m https://github.com/zephyrproject-rtos/gsoc-2022-arduino-core.git
west init -l Arduino-Zephyr-API/
west update
git clone https://github.com/arduino/ArduinoCore-API.git ArduinoCore-API
cp -r ArduinoCore-API/api modules/lib/Arduino-Zephyr-API/cores/arduino/.
mkdir -p modules/lib
ln -s Arduino-Zephyr-API modules/lib/
cp -rfp ArduinoCore-API/api Arduino-Zephyr-API/cores/arduino/

- name: Build fade
working-directory: Arduino-Zephyr-API
run: |
west build -p -b arduino_nano_33_ble_sense samples/fade
west build -p -b arduino_nano_33_ble/nrf52840/sense samples/fade

- name: Build i2cdemo
working-directory: Arduino-Zephyr-API
run: |
west build -p -b arduino_nano_33_ble_sense samples/i2cdemo
west build -p -b arduino_nano_33_ble/nrf52840/sense samples/i2cdemo

- name: Build adc
working-directory: Arduino-Zephyr-API
run: |
west build -p -b beagleconnect_freedom samples/analog_input
west build -p -b beagleconnect_freedom/cc1352p7 samples/analog_input

- name: Archive firmware
uses: actions/upload-artifact@v4
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/checkpatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Calculate PR commits + 1'
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
run: |
echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
wget https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/refs/heads/main/scripts/checkpatch.pl
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
- name: Run checkpatch review
uses: webispy/checkpatch-action@v9
env:
CHECKPATCH_COMMAND: perl ./checkpatch.pl

13 changes: 9 additions & 4 deletions .github/workflows/license_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ name: Scancode

on: [pull_request]

permissions:
contents: read

jobs:
scancode_job:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
name: Scan code for licenses
steps:
- name: Checkout the code
uses: actions/checkout@v4
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Scan the code
id: scancode
uses: zephyrproject-rtos/action_scancode@v4
uses: zephyrproject-rtos/action_scancode@23ef91ce31cd4b954366a7b71eea47520da9b380 # v4
with:
directory-to-scan: 'scan/'
- name: Artifact Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: scancode
path: ./artifacts
Expand Down
90 changes: 22 additions & 68 deletions cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2022 Dhruva Gole
* Copyright (c) 2025 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -14,87 +15,40 @@
#include <zephyr/drivers/adc.h>
#include <zephyr/drivers/i2c.h>

#define DIGITAL_PIN_EXISTS(n, p, i, dev, num) \
(((dev == DT_REG_ADDR(DT_PHANDLE_BY_IDX(n, p, i))) && \
(num == DT_PHA_BY_IDX(n, p, i, pin))) \
? 1 \
: 0)

/* Check all pins are defined only once */
#define DIGITAL_PIN_CHECK_UNIQUE(i, _) \
((DT_FOREACH_PROP_ELEM_SEP_VARGS( \
DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, (+), \
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), digital_pin_gpios, i)), \
DT_PHA_BY_IDX(DT_PATH(zephyr_user), digital_pin_gpios, i, pin))) == 1)

#if !LISTIFY(DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios), DIGITAL_PIN_CHECK_UNIQUE, (&&))
#error "digital_pin_gpios has duplicate definition"
#endif

#undef DIGITAL_PIN_CHECK_UNIQUE
#define ZARD_ADD_NGPIOS(i, n, p) DT_PROP(DT_PROP_BY_IDX(n, p, i), ngpios) +
#define ZARD_ACCUM_NGPIOS(n, p, i, nd) \
COND_CODE_1(DT_SAME_NODE(DT_PROP_BY_IDX(n, p, i), nd), \
(LISTIFY(i, ZARD_ADD_NGPIOS, (), n, p)), ())
#define ZARD_GLOBAL_GPIO_NUM(n, p, i) \
DT_FOREACH_PROP_ELEM_VARGS(DT_PATH(zephyr_user), gpio_ports, ZARD_ACCUM_NGPIOS, \
DT_PHANDLE_BY_IDX(n, p, i)) \
DT_PHA_BY_IDX(n, p, i, pin)

#ifndef LED_BUILTIN

/* Return the index of it if matched, oterwise return 0 */
#define LED_BUILTIN_INDEX_BY_REG_AND_PINNUM(n, p, i, dev, num) \
(DIGITAL_PIN_EXISTS(n, p, i, dev, num) ? i : 0)

/* Only matched pin returns non-zero value, so the sum is matched pin's index */
#define DIGITAL_PIN_GPIOS_FIND_PIN(dev, pin) \
DT_FOREACH_PROP_ELEM_SEP_VARGS(DT_PATH(zephyr_user), digital_pin_gpios, \
LED_BUILTIN_INDEX_BY_REG_AND_PINNUM, (+), dev, pin)

#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), builtin_led_gpios) && \
(DT_PROP_LEN(DT_PATH(zephyr_user), builtin_led_gpios) > 0)

#if !(DT_FOREACH_PROP_ELEM_SEP_VARGS( \
DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, (+), \
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), builtin_led_gpios, 0)), \
DT_PHA_BY_IDX(DT_PATH(zephyr_user), builtin_led_gpios, 0, pin)) > 0)
#warning "pin not found in digital_pin_gpios"
#else
#define LED_BUILTIN \
DIGITAL_PIN_GPIOS_FIND_PIN( \
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), builtin_led_gpios, 0)), \
DT_PHA_BY_IDX(DT_PATH(zephyr_user), builtin_led_gpios, 0, pin))
#endif

/* If digital-pin-gpios is not defined, tries to use the led0 alias */
#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), builtin_led_gpios) \
&& (DT_PROP_LEN(DT_PATH(zephyr_user), builtin_led_gpios) > 0)
#define LED_BUILTIN ZARD_GLOBAL_GPIO_NUM(DT_PATH(zephyr_user), builtin_led_gpios, 0)
#elif DT_NODE_EXISTS(DT_ALIAS(led0))

#if !(DT_FOREACH_PROP_ELEM_SEP_VARGS(DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, \
(+), DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_ALIAS(led0), gpios, 0)), \
DT_PHA_BY_IDX(DT_ALIAS(led0), gpios, 0, pin)) > 0)
#warning "pin not found in digital_pin_gpios"
#else
#define LED_BUILTIN \
DIGITAL_PIN_GPIOS_FIND_PIN(DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_ALIAS(led0), gpios, 0)), \
DT_PHA_BY_IDX(DT_ALIAS(led0), gpios, 0, pin))
#define LED_BUILTIN ZARD_GLOBAL_GPIO_NUM(DT_ALIAS(led0), gpios, 0)
#endif

#endif // builtin_led_gpios

#endif // LED_BUILTIN

#define DN_ENUMS(n, p, i) D##i = i

/*
* expand as
* enum digitalPins { D0, D1, ... LED... NUM_OF_DIGITAL_PINS };
* enum digitalPins { D0, D1, ... };
*/
#define ZARD_DN_ENUMS(n, p, i) D##i = ZARD_GLOBAL_GPIO_NUM(n, p, i)
enum digitalPins {
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), digital_pin_gpios, DN_ENUMS, (, )),
NUM_OF_DIGITAL_PINS
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), digital_pin_gpios, ZARD_DN_ENUMS, (, )),
NUM_OF_DIGITAL_PINS
};

#ifdef CONFIG_ADC

#define AN_ENUMS(n, p, i) A ## i = DIGITAL_PIN_GPIOS_FIND_PIN( \
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
enum analogPins { DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user),
adc_pin_gpios, AN_ENUMS) };

#define ZARD_AN_ENUMS(n, p, i) A##i = ZARD_GLOBAL_GPIO_NUM(n, p, i)
enum analogPins {
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), adc_pin_gpios, ZARD_AN_ENUMS, (, )),
NUM_OF_ANALOG_PINS
};
#endif

void interrupts(void);
Expand Down
Loading