Skip to content

Pull in changes from -next #95

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

Merged
merged 6 commits into from
May 23, 2024
Merged
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
21 changes: 11 additions & 10 deletions .github/workflows/checkpatch.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: CI
name: checkpatch review

# Controls when the workflow will run
on:
Expand All @@ -15,15 +15,16 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
my_review:
name: checkpatch review
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: checkpatch.pl PR review
uses: webispy/checkpatch-action@v8
- name: 'Calculate PR commits + 1'
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
- name: Run checkpatch review
uses: webispy/checkpatch-action@v9

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if (CONFIG_ARDUINO_API)
add_subdirectory(cores)
add_subdirectory(variants)
add_subdirectory(libraries)
zephyr_include_directories(variants/${BOARD})
endif()

5 changes: 5 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CODEOWNERS for autoreview assigning in github

Check failure on line 1 in CODEOWNERS

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: It's generally not useful to have the filename in the file

# https://help.github.com/en/articles/about-code-owners#codeowners-syntax

/* @DhruvaG2000 @szczys @beriberikix @soburi
3 changes: 1 addition & 2 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

config ARDUINO_API
bool "ARDUINO_API"
imply CPLUSPLUS
imply CPP
imply GPIO
imply CPLUSPLUS
imply I2C
imply NEWLIB_LIBC_FLOAT_PRINTF
imply CBPRINTF_FP_SUPPORT
Expand Down
91 changes: 90 additions & 1 deletion cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,101 @@
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include "api/ArduinoAPI.h"

#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pwm.h>
#include <zephyr/drivers/adc.h>
#include <zephyr/kernel.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

#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( \

Check failure on line 50 in cores/arduino/Arduino.h

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 101 exceeds 100 columns
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 */
#elif DT_NODE_EXISTS(DT_ALIAS(led0))

#if !(DT_FOREACH_PROP_ELEM_SEP_VARGS(DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, \

Check failure on line 65 in cores/arduino/Arduino.h

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 101 exceeds 100 columns
(+), 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))
#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 {
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), digital_pin_gpios, DN_ENUMS, (, )),

Check failure on line 86 in cores/arduino/Arduino.h

View workflow job for this annotation

GitHub Actions / checkpatch review

ERROR: space prohibited before that close parenthesis ')'
NUM_OF_DIGITAL_PINS
};

const struct gpio_dt_spec arduino_pins[] = {DT_FOREACH_PROP_ELEM_SEP(
DT_PATH(zephyr_user), digital_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))};

Check failure on line 91 in cores/arduino/Arduino.h

View workflow job for this annotation

GitHub Actions / checkpatch review

ERROR: space prohibited before that close parenthesis ')'

#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) };

#endif

#include <variants.h>
#include <zephyrPrint.h>
Expand Down
1 change: 1 addition & 0 deletions documentation/variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Once completed, continue here by adding a variant for your custom board.
- [X] Arduino Nano ble sense 33
- [X] Arduino Nano ble 33
- [X] Arduino Nano 33 iot
- [X] Beagleconnect Freedom

## Planned Support: (TODO)
- [ ] Particle Xenon
Expand Down
3 changes: 0 additions & 3 deletions variants/CMakeLists.txt

This file was deleted.

11 changes: 0 additions & 11 deletions variants/arduino_mkrzero/arduino_mkrzero_pinmap.h

This file was deleted.

5 changes: 5 additions & 0 deletions variants/arduino_mkrzero/variants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* Copyright (c) 2022 Dhruva Gole
*
* SPDX-License-Identifier: Apache-2.0
*/
13 changes: 0 additions & 13 deletions variants/arduino_nano_33_ble/arduino_nano_33_ble_pinmap.h

This file was deleted.

5 changes: 5 additions & 0 deletions variants/arduino_nano_33_ble/variants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* Copyright (c) 2022 Dhruva Gole
*
* SPDX-License-Identifier: Apache-2.0
*/

This file was deleted.

5 changes: 5 additions & 0 deletions variants/arduino_nano_33_ble_sense/variants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* Copyright (c) 2022 Dhruva Gole
*
* SPDX-License-Identifier: Apache-2.0
*/
13 changes: 0 additions & 13 deletions variants/arduino_nano_33_iot/arduino_nano_33_iot_pinmap.h

This file was deleted.

5 changes: 5 additions & 0 deletions variants/arduino_nano_33_iot/variants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* Copyright (c) 2022 Dhruva Gole
*
* SPDX-License-Identifier: Apache-2.0
*/
51 changes: 51 additions & 0 deletions variants/beagleconnect_freedom/beagleconnect_freedom.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2024 Ayush Singh <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
zephyr,user {
digital-pin-gpios =
<&gpio0 16 GPIO_ACTIVE_HIGH>, /* D0 - MB1 INT */
<&gpio0 20 GPIO_ACTIVE_HIGH>, /* D1 - MB2 INT */
<&gpio0 17 GPIO_ACTIVE_HIGH>, /* D2 - MB1 PWM */
<&gpio0 28 GPIO_ACTIVE_HIGH>, /* D3 - MB1 CS - A5 */
<&gpio0 21 GPIO_ACTIVE_HIGH>, /* D4 - MB2 UART1 RX */
<&gpio0 22 GPIO_ACTIVE_HIGH>, /* D5 - MB2 UART1 TX */
<&gpio0 19 GPIO_ACTIVE_HIGH>, /* D6 - MB2 PWM */
<&gpio0 27 GPIO_ACTIVE_HIGH>, /* D7 - MB2 CS - A4 */
<&gpio0 9 GPIO_ACTIVE_HIGH>, /* D8 - MB1/2 PICO */
<&gpio0 10 GPIO_ACTIVE_HIGH>, /* D9 - MB1/2 SCK */
<&gpio0 11 GPIO_ACTIVE_HIGH>, /* D10 - MB1/2 POCI */
<&gpio0 26 GPIO_ACTIVE_HIGH>, /* D11 - MB1/2 SDA - A2 */
<&gpio0 25 GPIO_ACTIVE_HIGH>, /* D12 - MB1/2 SCL - A3 */
<&gpio0 12 GPIO_ACTIVE_HIGH>, /* D13 - MB1 UART0 RX */
<&gpio0 13 GPIO_ACTIVE_HIGH>, /* D14 - MB1 UART0 TX */
<&gpio0 23 GPIO_ACTIVE_HIGH>, /* D15 - MB1 AN - A0 */
<&gpio0 24 GPIO_ACTIVE_HIGH>, /* D16 - MB2 AN - A1 */
<&gpio0 5 GPIO_ACTIVE_HIGH>, /* D17 - MB2 RST */
<&gpio0 6 GPIO_ACTIVE_HIGH>, /* D18 - MB1 RST */
<&gpio0 7 GPIO_ACTIVE_HIGH>, /* D19 - on-board sensor INT */
<&gpio0 8 GPIO_ACTIVE_HIGH>, /* D20 - flash CS */
<&gpio0 14 GPIO_ACTIVE_HIGH>, /* D21 - on-board sensor I2C enable */
<&gpio0 15 GPIO_ACTIVE_HIGH>, /* D22 - BOOT button */
<&gpio0 18 GPIO_ACTIVE_HIGH>; /* D23 - LINK LED */

pwm-pin-gpios =
<&gpio0 17 GPIO_ACTIVE_HIGH>, /* D2 - MB1 PWM */
<&gpio0 3 GPIO_ACTIVE_HIGH>; /* D6 - MB2 PWM */

adc-pin-gpios =
<&gpio0 23 GPIO_ACTIVE_HIGH>, /* D15 - MB1 AN - A0 */
<&gpio0 24 GPIO_ACTIVE_HIGH>, /* D16 - MB2 AN - A1 */
<&gpio0 26 GPIO_ACTIVE_HIGH>, /* D11 - MB1/2 SDA - A2 */
<&gpio0 25 GPIO_ACTIVE_HIGH>, /* D12 - MB1/2 SCL - A3 */
<&gpio0 27 GPIO_ACTIVE_HIGH>, /* D7 - MB2 CS - A4 */
<&gpio0 28 GPIO_ACTIVE_HIGH>; /* D3 - MB1 CS - A5 */

builtin-led-gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; /* 2.4GHz TX/RX */
serials = <&uart0 &uart1>;
i2cs = <&i2c0>;
};
};
6 changes: 6 additions & 0 deletions variants/beagleconnect_freedom/variants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright (c) 2024 Ayush Singh <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

/* All the pins that are 100 + x are gpio1 pins and < 100 are in gpio0 */
#pragma once
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/device.h>

#define LED_BUILTIN 4
#define YELLOW_LED 3
Expand Down
14 changes: 0 additions & 14 deletions variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840_pinmap.h

This file was deleted.

5 changes: 5 additions & 0 deletions variants/nrf52840dk_nrf52840/variants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* Copyright (c) 2022 Mike Szczys
*
* SPDX-License-Identifier: Apache-2.0
*/
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#ifndef INCLUDE_NRF1960DK_NRF1960_PINMAP_H
#define INCLUDE_NRF1960DK_NRF1960_PINMAP_H

#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/kernel.h>

#define NRF9160DK_LED_1 D2 // P0.02
#define NRF9160DK_LED_2 D3 // P0.03
#define NRF9160DK_LED_3 D4 // P0.04
Expand Down
Loading
Loading