Skip to content

Commit 4e63d9c

Browse files
committed
cores: arduino: Format with clang-format
Use a formatter to standardize indentation. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
1 parent 32ef6b1 commit 4e63d9c

File tree

8 files changed

+499
-528
lines changed

8 files changed

+499
-528
lines changed

cores/arduino/Arduino.h

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
#include <zephyr/drivers/i2c.h>
1616

1717
#define DIGITAL_PIN_EXISTS(n, p, i, dev, num) \
18-
(((dev == DT_REG_ADDR(DT_PHANDLE_BY_IDX(n, p, i))) && \
19-
(num == DT_PHA_BY_IDX(n, p, i, pin))) \
20-
? 1 \
21-
: 0)
18+
(((dev == DT_REG_ADDR(DT_PHANDLE_BY_IDX(n, p, i))) && (num == DT_PHA_BY_IDX(n, p, i, pin))) ? \
19+
1 : \
20+
0)
2221

2322
/* Check all pins are defined only once */
2423
#define DIGITAL_PIN_CHECK_UNIQUE(i, _) \
25-
((DT_FOREACH_PROP_ELEM_SEP_VARGS( \
26-
DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, (+), \
27-
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), digital_pin_gpios, i)), \
24+
((DT_FOREACH_PROP_ELEM_SEP_VARGS( \
25+
DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, (+), \
26+
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), digital_pin_gpios, i)), \
2827
DT_PHA_BY_IDX(DT_PATH(zephyr_user), digital_pin_gpios, i, pin))) == 1)
2928

3029
#if !LISTIFY(DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios), DIGITAL_PIN_CHECK_UNIQUE, (&&))
@@ -38,17 +37,17 @@
3837
(DIGITAL_PIN_EXISTS(n, p, i, dev, num) ? i : 0)
3938

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

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

48-
#if !(DT_FOREACH_PROP_ELEM_SEP_VARGS( \
49-
DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, (+), \
50-
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), builtin_led_gpios, 0)), \
51-
DT_PHA_BY_IDX(DT_PATH(zephyr_user), builtin_led_gpios, 0, pin)) > 0)
47+
#if !(DT_FOREACH_PROP_ELEM_SEP_VARGS( \
48+
DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, (+), \
49+
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), builtin_led_gpios, 0)), \
50+
DT_PHA_BY_IDX(DT_PATH(zephyr_user), builtin_led_gpios, 0, pin)) > 0)
5251
#warning "pin not found in digital_pin_gpios"
5352
#else
5453
#define ZARD_LED_BUILTIN \
@@ -60,9 +59,10 @@
6059
/* If digital-pin-gpios is not defined, tries to use the led0 alias */
6160
#elif DT_NODE_EXISTS(DT_ALIAS(led0))
6261

63-
#if !(DT_FOREACH_PROP_ELEM_SEP_VARGS(DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, \
64-
(+), DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_ALIAS(led0), gpios, 0)), \
65-
DT_PHA_BY_IDX(DT_ALIAS(led0), gpios, 0, pin)) > 0)
62+
#if !(DT_FOREACH_PROP_ELEM_SEP_VARGS(DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, \
63+
(+), \
64+
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_ALIAS(led0), gpios, 0)), \
65+
DT_PHA_BY_IDX(DT_ALIAS(led0), gpios, 0, pin)) > 0)
6666
#warning "pin not found in digital_pin_gpios"
6767
#else
6868
#define ZARD_LED_BUILTIN \
@@ -85,11 +85,13 @@ enum digitalPins {
8585

8686
#ifdef CONFIG_ADC
8787

88-
#define AN_ENUMS(n, p, i) A ## i = DIGITAL_PIN_GPIOS_FIND_PIN( \
89-
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
90-
DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
91-
enum analogPins { DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user),
92-
adc_pin_gpios, AN_ENUMS) };
88+
#define AN_ENUMS(n, p, i) \
89+
A##i = DIGITAL_PIN_GPIOS_FIND_PIN(DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
90+
DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
91+
92+
enum analogPins {
93+
DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), adc_pin_gpios, AN_ENUMS)
94+
};
9395

9496
#endif
9597

cores/arduino/apiCommon.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
#include "zephyrInternal.h"
99

1010
extern "C" {
11-
int32_t map_i32(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max);
12-
uint16_t makeWord_w(uint16_t w);
13-
uint16_t makeWord_hl(byte h, byte l);
11+
int32_t map_i32(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max);
12+
uint16_t makeWord_w(uint16_t w);
13+
uint16_t makeWord_hl(byte h, byte l);
1414
}
1515

16-
long map(long x, long in_min, long in_max, long out_min, long out_max)
17-
{
18-
return map_i32(x, in_min, in_max, out_min, out_max);
16+
long map(long x, long in_min, long in_max, long out_min, long out_max) {
17+
return map_i32(x, in_min, in_max, out_min, out_max);
1918
}
2019

2120
uint16_t makeWord(uint16_t w) {
22-
return makeWord_w(w);
21+
return makeWord_w(w);
2322
}
23+
2424
uint16_t makeWord(byte h, byte l) {
25-
return makeWord_hl(h, l);
25+
return makeWord_hl(h, l);
2626
}

cores/arduino/main.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
#include "Arduino.h"
88

99
int main(void) {
10-
setup();
10+
setup();
1111

12-
for (;;) {
13-
loop();
14-
if (arduino::serialEventRun) arduino::serialEventRun();
15-
}
12+
for (;;) {
13+
loop();
14+
if (arduino::serialEventRun) {
15+
arduino::serialEventRun();
16+
}
17+
}
1618

17-
return 0;
19+
return 0;
1820
}

0 commit comments

Comments
 (0)