Skip to content

Commit 930c6bd

Browse files
committed
variants: add support for arduino_mkrzero
Add support for the arduino mkr zero board. - Add the LED builtin in arduino mkrzero - Add sercom as i2c because that's how it is described in arduino_mkrzero.dts: pinctrl-0 = <&sercom0_i2c_default>; Signed-off-by: Dhruva Gole <goledhruva@gmail.com>
1 parent 8a28d3a commit 930c6bd

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2022 Dhruva Gole <goledhruva@gmail.com>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/ {
7+
zephyr,user {
8+
d0_gpios = <&arduino_mkr_header 0 0>;
9+
d1_gpios = <&arduino_mkr_header 1 0>;
10+
d2_gpios = <&arduino_mkr_header 2 0>;
11+
d3_gpios = <&arduino_mkr_header 3 0>;
12+
d4_gpios = <&arduino_mkr_header 4 0>;
13+
d5_gpios = <&arduino_mkr_header 5 0>;
14+
d6_gpios = <&arduino_mkr_header 6 0>;
15+
d7_gpios = <&arduino_mkr_header 7 0>;
16+
d8_gpios = <&arduino_mkr_header 8 0>;
17+
d9_gpios = <&arduino_mkr_header 9 0>;
18+
d10_gpios = <&arduino_mkr_header 10 0>;
19+
d11_gpios = <&arduino_mkr_header 11 0>;
20+
d12_gpios = <&arduino_mkr_header 12 0>;
21+
d13_gpios = <&arduino_mkr_header 13 0>;
22+
d14_gpios = <&arduino_mkr_header 14 0>; /* D14 / A0 */
23+
d15_gpios = <&arduino_mkr_header 15 0>;
24+
d16_gpios = <&arduino_mkr_header 16 0>;
25+
d17_gpios = <&arduino_mkr_header 17 0>;
26+
d18_gpios = <&arduino_mkr_header 18 0>; /* D18 / A4 / I2C-SDA */
27+
d19_gpios = <&arduino_mkr_header 19 0>; /* D19 / A5 / I2C-SCL */
28+
d20_gpios = <&arduino_mkr_header 20 0>;
29+
d21_gpios = <&arduino_mkr_header 21 0>;
30+
};
31+
};
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright (c) 2022 Dhruva Gole
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* All the pins that are 100 + x are gpio1 pins and < 100 are in gpio0 */
8+
#pragma once
9+
#include <zephyr/drivers/gpio.h>
10+
#include <zephyr/kernel.h>
11+
#include <zephyr/drivers/i2c.h>
12+
#include <zephyr/device.h>
13+
14+
#define LED_BUILTIN 22
15+
#define LED0_NODE DT_ALIAS(led0)
16+
17+
static struct gpio_dt_spec d0 =
18+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d0_gpios);
19+
static struct gpio_dt_spec d1 =
20+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d1_gpios);
21+
static struct gpio_dt_spec d2 =
22+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d2_gpios);
23+
static struct gpio_dt_spec d3 =
24+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d3_gpios);
25+
static struct gpio_dt_spec d4 =
26+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d4_gpios);
27+
static struct gpio_dt_spec d5 =
28+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d5_gpios);
29+
static struct gpio_dt_spec d6 =
30+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d6_gpios);
31+
static struct gpio_dt_spec d7 =
32+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d7_gpios);
33+
static struct gpio_dt_spec d8 =
34+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d8_gpios);
35+
static struct gpio_dt_spec d9 =
36+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d9_gpios);
37+
static struct gpio_dt_spec d10 =
38+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d10_gpios);
39+
static struct gpio_dt_spec d11 =
40+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d11_gpios);
41+
static struct gpio_dt_spec d12 =
42+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d12_gpios);
43+
static struct gpio_dt_spec d13 =
44+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d13_gpios);
45+
static struct gpio_dt_spec d14 =
46+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d13_gpios);
47+
static struct gpio_dt_spec d15 =
48+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d15_gpios);
49+
static struct gpio_dt_spec d16 =
50+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d16_gpios);
51+
static struct gpio_dt_spec d17 =
52+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d17_gpios);
53+
static struct gpio_dt_spec d18 =
54+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d18_gpios);
55+
static struct gpio_dt_spec d19 =
56+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d19_gpios);
57+
static struct gpio_dt_spec d20 =
58+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d20_gpios);
59+
static struct gpio_dt_spec d21 =
60+
GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d21_gpios);
61+
static struct gpio_dt_spec led_builtin = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
62+
63+
static struct gpio_dt_spec *arduino_pins[23] = {
64+
&d0, &d1, &d2, &d3, &d4, &d5, &d6, &d7,
65+
&d8, &d9, &d10, &d11, &d12, &d13, &d14, &d15,
66+
&d16, &d17, &d18, &d19, &d20, &d21, &led_builtin};
67+
68+
enum digitalPins {
69+
D0,
70+
D1,
71+
D2,
72+
D3,
73+
D4,
74+
D5,
75+
D6,
76+
D7,
77+
D8,
78+
D9,
79+
D10,
80+
D11,
81+
D12,
82+
D13,
83+
D14,
84+
D15,
85+
D16,
86+
D17,
87+
D18,
88+
D19,
89+
D20,
90+
D21,
91+
LED
92+
};
93+
94+
const static struct device *i2c_dev = DEVICE_DT_GET(DT_NODELABEL(sercom0));

variants/variants.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
#ifdef CONFIG_BOARD_NRF52840DK_NRF52840
1111
#include "nrf52840dk_nrf52840_pinmap.h"
1212
#endif /* CONFIG_BOARD_NRF52840DK_NRF52840 */
13+
#ifdef CONFIG_BOARD_ARDUINO_MKRZERO
14+
#include "arduino_mkrzero_pinmap.h"
15+
#endif // CONFIG_BOARD_ARDUINO_MKRZERO
16+

0 commit comments

Comments
 (0)