Skip to content

Ci cd ztrial #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: ci-cd/compliance
Choose a base branch
from
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
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
container: zephyrprojectrtos/ci:latest
env:
CMAKE_PREFIX_PATH: /opt/toolchains
steps:
- name: Checkout
uses: actions/checkout@v2
with:
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 update
git clone https://github.com/arduino/ArduinoCore-API.git ArduinoCore-API
sed '/WCharacter.h/ s/./\/\/ &/' ArduinoCore-API/api/ArduinoAPI.h > ArduinoCore-API/api/tmpArduinoAPI.h
mv ArduinoCore-API/api/tmpArduinoAPI.h ArduinoCore-API/api/ArduinoAPI.h
cp -r ArduinoCore-API/api modules/lib/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

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

- name: Archive firmware
uses: actions/upload-artifact@v2
with:
name: firmware
path: Arduino-Zephyr-API/build/zephyr/zephyr.*
14 changes: 10 additions & 4 deletions cores/arduino/zephyrCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,17 @@ void handleGpioCallback(const struct device *port, struct gpio_callback *cb, uin
#ifdef CONFIG_PWM

#define PWM_DT_SPEC(n,p,i) PWM_DT_SPEC_GET_BY_IDX(n, i),
#define PWM_PINS(n,p,i) DT_PROP_BY_IDX(n, p, i),
#define PWM_PINS(n, p, 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)),

const struct pwm_dt_spec arduino_pwm[] =
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), pwms, PWM_DT_SPEC) };

/* pwm-pins node provides a mapping digital pin numbers to pwm channels */
const pin_size_t arduino_pwm_pins[] =
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), pwm_pins, PWM_PINS) };
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), pwm_pin_gpios, PWM_PINS) };

size_t pwm_pin_index(pin_size_t pinNumber) {
for(size_t i=0; i<ARRAY_SIZE(arduino_pwm_pins); i++) {
Expand All @@ -136,15 +139,18 @@ size_t pwm_pin_index(pin_size_t pinNumber) {
#ifdef CONFIG_ADC

#define ADC_DT_SPEC(n,p,i) ADC_DT_SPEC_GET_BY_IDX(n, i),
#define ADC_PINS(n,p,i) DT_PROP_BY_IDX(n, p, i),
#define ADC_PINS(n, p, 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)),
#define ADC_CH_CFG(n,p,i) arduino_adc[i].channel_cfg,

const struct adc_dt_spec arduino_adc[] =
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), io_channels, ADC_DT_SPEC) };

/* io-channel-pins node provides a mapping digital pin numbers to adc channels */
const pin_size_t arduino_analog_pins[] =
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), io_channel_pins, ADC_PINS) };
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), adc_pin_gpios, ADC_PINS) };

struct adc_channel_cfg channel_cfg[ARRAY_SIZE(arduino_analog_pins)] =
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), io_channels, ADC_CH_CFG) };
Expand Down
13 changes: 9 additions & 4 deletions documentation/variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ variants/

### DeviceTree Overlay files for Arduino boards

This module requires that your Arduino header pins be mapped in the DeviceTree
to 'digital-pin-gpios' array that child of a `zephyr,user` node. Follow the
examples in the variants directory to create an overlay file and a header file
for your board.
The Arduino API requires pin mapping definitions to use Arduino-style pin numbers
(pin numbers printed on the board, not GPIO numbers).
The pin-mapping node is under the `zephyr,user` node of DTS.
`digital-pin-gpios` defines digital input/output pins that is D0, D1, ..,
`adc-pin-gpios` defines analog input pins that is A0, A1, ... .
`pwm-pin-gpios` defines PWM pins.
Each pin specifies in the form of a GPIO cell.
Usually, it is in the form of `<[port] [pin-number] [flag]>`.
You can also use the Arduino header node definition here.

### Overlays using previously-defined Arduino headers

Expand Down
1 change: 1 addition & 0 deletions samples/threads_arduino/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void setup()
}
void loop()
{
printk("THIS IS A BAD COMIT");
digitalWrite(D10, HIGH);
delay(300);
digitalWrite(D10, LOW);
Expand Down
13 changes: 11 additions & 2 deletions variants/arduino_mkrzero/arduino_mkrzero.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,19 @@
<&arduino_mkr_header 21 0>,
<&portb 8 0>;

pwm-pin-gpios = <&arduino_mkr_header 2 0>,
<&arduino_mkr_header 3 0>;

adc-pin-gpios = <&arduino_mkr_header 15 0>,
<&arduino_mkr_header 16 0>,
<&arduino_mkr_header 17 0>,
<&arduino_mkr_header 18 0>,
<&arduino_mkr_header 19 0>,
<&arduino_mkr_header 20 0>,
<&arduino_mkr_header 21 0>;

pwms = <&tcc0 2 255>,
<&tcc0 3 255>;
pwm-pins = <2 3>;

io-channels = <&adc 0>,
<&adc 10>,
Expand All @@ -43,7 +53,6 @@
<&adc 5>,
<&adc 6>,
<&adc 7>;
io-channel-pins = <15 16 17 18 19 20 21>;

serials = <&sercom5>;
i2cs = <&sercom0>;
Expand Down
23 changes: 19 additions & 4 deletions variants/arduino_nano_33_ble/arduino_nano_33_ble.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,32 @@
<&arduino_nano_header 20 0>,
<&arduino_nano_header 21 0>;

pwm-pin-gpios = <&arduino_nano_header 3 0>,
<&arduino_nano_header 5 0>,
<&arduino_nano_header 6 0>,
<&arduino_nano_header 13 0>,
<&arduino_nano_header 9 0>,
<&arduino_nano_header 10 0>,
<&arduino_nano_header 11 0>;

adc-pin-gpios = <&arduino_nano_header 14 0>,
<&arduino_nano_header 15 0>,
<&arduino_nano_header 16 0>,
<&arduino_nano_header 17 0>,
<&arduino_nano_header 18 0>,
<&arduino_nano_header 19 0>,
<&arduino_nano_header 20 0>,
<&arduino_nano_header 21 0>;

builtin-led-gpios = <&arduino_nano_header 13 0>;

pwms = <&pwm1 1 255 PWM_POLARITY_NORMAL>,
<&pwm1 2 255 PWM_POLARITY_NORMAL>,
<&pwm1 3 255 PWM_POLARITY_NORMAL>,
<&pwm2 0 255 PWM_POLARITY_NORMAL>,
<&pwm2 1 255 PWM_POLARITY_NORMAL>,
<&pwm2 2 255 PWM_POLARITY_NORMAL>,
<&pwm2 3 255 PWM_POLARITY_NORMAL>;
pwm-pins = <3 5 6 13 9 10 11>;

io-channels = <&adc 2>,
<&adc 3>,
Expand All @@ -40,12 +58,9 @@
<&adc 0>,
<&adc 4>,
<&adc 1>;
io-channel-pins = <14 15 16 17 18 19 20 21>;

serials = <&uart0>;
i2cs = <&arduino_nano_i2c>;

builtin-led-gpios = <&arduino_nano_header 13 0>;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,32 @@
<&arduino_nano_header 20 0>,
<&arduino_nano_header 21 0>;

pwm-pin-gpios = <&arduino_nano_header 3 0>,
<&arduino_nano_header 5 0>,
<&arduino_nano_header 6 0>,
<&arduino_nano_header 13 0>,
<&arduino_nano_header 9 0>,
<&arduino_nano_header 10 0>,
<&arduino_nano_header 11 0>;

adc-pin-gpios = <&arduino_nano_header 14 0>,
<&arduino_nano_header 15 0>,
<&arduino_nano_header 16 0>,
<&arduino_nano_header 17 0>,
<&arduino_nano_header 18 0>,
<&arduino_nano_header 19 0>,
<&arduino_nano_header 20 0>,
<&arduino_nano_header 21 0>;

builtin-led-gpios = <&arduino_nano_header 13 0>;

pwms = <&pwm1 1 255 PWM_POLARITY_NORMAL>,
<&pwm1 2 255 PWM_POLARITY_NORMAL>,
<&pwm1 3 255 PWM_POLARITY_NORMAL>,
<&pwm2 0 255 PWM_POLARITY_NORMAL>,
<&pwm2 1 255 PWM_POLARITY_NORMAL>,
<&pwm2 2 255 PWM_POLARITY_NORMAL>,
<&pwm2 3 255 PWM_POLARITY_NORMAL>;
pwm-pins = <3 5 6 13 9 10 11>;

io-channels = <&adc 2>,
<&adc 3>,
Expand All @@ -40,12 +58,9 @@
<&adc 0>,
<&adc 4>,
<&adc 1>;
io-channel-pins = <14 15 16 17 18 19 20 21>;

serials = <&uart0>;
i2cs = <&arduino_nano_i2c>;

builtin-led-gpios = <&arduino_nano_header 13 0>;
};
};

Expand Down
20 changes: 18 additions & 2 deletions variants/arduino_nano_33_iot/arduino_nano_33_iot.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@
<&arduino_nano_header 20 0>,
<&arduino_nano_header 21 0>;

pwm-pin-gpios = <&arduino_nano_header 6 0>,
<&arduino_nano_header 5 0>,
<&arduino_nano_header 17 0>,
<&arduino_nano_header 12 0>,
<&arduino_nano_header 2 0>,
<&arduino_nano_header 3 0>,
<&arduino_nano_header 9 0>,
<&arduino_nano_header 10 0>;

adc-pin-gpios = <&arduino_nano_header 14 0>,
<&arduino_nano_header 15 0>,
<&arduino_nano_header 16 0>,
<&arduino_nano_header 17 0>,
<&arduino_nano_header 18 0>,
<&arduino_nano_header 19 0>,
<&arduino_nano_header 20 0>,
<&arduino_nano_header 21 0>;

pwms = <&tcc0 0 255>,
<&tcc0 1 255>,
<&tcc0 2 255>,
Expand All @@ -33,7 +51,6 @@
<&tcc0 5 255>,
<&tcc0 6 255>,
<&tcc0 7 255>;
pwm-pins = <6 5 17 12 2 3 9 10>;

io-channels = <&adc 0>,
<&adc 10>,
Expand All @@ -42,7 +59,6 @@
<&adc 5>,
<&adc 6>,
<&adc 7>;
io-channel-pins = <14 15 16 17 18 19 20 21>;

serials = <&sercom5>;
i2cs = <&arduino_nano_i2c>;
Expand Down
17 changes: 15 additions & 2 deletions variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,34 @@
<&arduino_header 5 0>,
<&gpio0 13 GPIO_ACTIVE_LOW>;

pwm-pin-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>,
<&arduino_header 9 0>,
<&arduino_header 11 0>,
<&arduino_header 12 0>,
<&arduino_header 15 0>,
<&arduino_header 16 0>,
<&arduino_header 17 0>;

adc-pin-gpios = <&arduino_header 0 0>,
<&arduino_header 1 0>,
<&arduino_header 2 0>,
<&arduino_header 3 0>,
<&arduino_header 4 0>,
<&arduino_header 5 0>;

pwms = <&pwm0 1 255 PWM_POLARITY_NORMAL>,
<&pwm0 2 255 PWM_POLARITY_NORMAL>,
<&pwm0 3 255 PWM_POLARITY_NORMAL>,
<&pwm1 0 255 PWM_POLARITY_NORMAL>,
<&pwm1 1 255 PWM_POLARITY_NORMAL>,
<&pwm1 2 255 PWM_POLARITY_NORMAL>;
pwm-pins = <22 3 5 6 9 10 11>;

io-channels = <&arduino_adc 0>,
<&arduino_adc 1>,
<&arduino_adc 2>,
<&arduino_adc 3>,
<&arduino_adc 4>,
<&arduino_adc 5>;
io-channel-pins = <16 17 18 19 20 21>;
};
};

Expand Down
12 changes: 7 additions & 5 deletions variants/variants.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
(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 LED_BUILTIN_FIND_DIGITAL_PIN(dev, pin) \
#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)

Expand All @@ -58,7 +58,7 @@
#warning "pin not found in digital_pin_gpios"
#else
#define LED_BUILTIN \
LED_BUILTIN_FIND_DIGITAL_PIN( \
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
Expand All @@ -72,7 +72,7 @@
#warning "pin not found in digital_pin_gpios"
#else
#define LED_BUILTIN \
LED_BUILTIN_FIND_DIGITAL_PIN(DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_ALIAS(led0), gpios, 0)), \
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))
#endif

Expand All @@ -96,8 +96,10 @@ const struct gpio_dt_spec arduino_pins[] = {DT_FOREACH_PROP_ELEM_SEP(

#ifdef CONFIG_ADC

#define AN_ENUMS(n, p, i) A ## i = DT_PROP_BY_IDX(n, p, i),
#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),
io_channel_pins, AN_ENUMS) };
adc_pin_gpios, AN_ENUMS) };

#endif
19 changes: 19 additions & 0 deletions west.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2022 Dhruva Gole <[email protected]>
# SPDX-License-Identifier: Apache-2.0

# NOTE: This is created to be used for CI/CD workflow. So use it only
# if you are in the zephyrproject directory or else things may break.

manifest:
self:
path: modules/lib/Arduino-Zephyr-API

remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos

projects:
- name: zephyr
remote: zephyrproject-rtos
revision: main
import: true