Skip to content

Commit ce6b872

Browse files
committed
boards/arduino-mkrzero: adapt implementation to use common code
1 parent 7cdc033 commit ce6b872

File tree

7 files changed

+30
-249
lines changed

7 files changed

+30
-249
lines changed

boards/arduino-mkrzero/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
MODULE = board
22

3+
DIRS = $(RIOTBOARD)/arduino-mkr-common
4+
35
include $(RIOTBASE)/Makefile.base
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ifneq (,$(filter saul_default,$(USEMODULE)))
2-
USEMODULE += saul_gpio
3-
endif
1+
include $(RIOTBOARD)/arduino-mkr-common/Makefile.dep
2+
3+
USEMODULE += sdcard_spi
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
# Put defined MCU peripherals here (in alphabetical order)
2-
FEATURES_PROVIDED += periph_cpuid
3-
FEATURES_PROVIDED += periph_gpio
4-
FEATURES_PROVIDED += periph_i2c
5-
FEATURES_PROVIDED += periph_spi
6-
FEATURES_PROVIDED += periph_timer
7-
FEATURES_PROVIDED += periph_uart
8-
9-
# Various other features (if any)
10-
FEATURES_PROVIDED += cpp
11-
FEATURES_PROVIDED += arduino
12-
13-
# The board MPU family (used for grouping by the CI system)
14-
FEATURES_MCU_GROUP = cortex_m0_2
1+
include $(RIOTBOARD)/arduino-mkr-common/Makefile.features
Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
# define the cpu used by Arduino/Genuino MKRZERO board
2-
export CPU = samd21
3-
export CPU_MODEL = samd21g18a_mkr
4-
export CFLAGS += -D__SAMD21G18A__
1+
USEMODULE += arduino-mkr-common
52

6-
# set default port depending on operating system
7-
PORT_LINUX ?= /dev/ttyACM0
8-
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
3+
include $(RIOTBOARD)/arduino-mkr-common/Makefile.include
94

10-
# define board specific flasher options
11-
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
12-
export OFLAGS = -O binary
13-
14-
# setup the boards dependencies
15-
include $(RIOTBOARD)/$(BOARD)/Makefile.dep
16-
17-
# setup serial terminal
18-
include $(RIOTMAKE)/tools/serial.inc.mk
5+
# add arduino-mkrzero include path
6+
INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include

boards/arduino-mkrzero/dist/flash.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@ elif [ `uname` = "Darwin" ]; then
1212
else
1313
echo "CAUTION: No flash tool for your host system found!"
1414
fi
15-
16-

boards/arduino-mkrzero/include/board.h

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,46 @@
2424

2525
#include "cpu.h"
2626
#include "periph_conf.h"
27-
#include "periph_cpu.h"
27+
#include "board_common.h"
2828
#include "arduino_pinmap.h"
2929

3030
#ifdef __cplusplus
3131
extern "C" {
3232
#endif
3333

3434
/**
35-
* @brief xtimer configuration
35+
* @name SD Card device configuration
3636
* @{
3737
*/
38-
#define XTIMER TIMER_0
39-
#define XTIMER_CHAN (0)
38+
#define SDCARD_SPI_PARAM_SPI (SPI_DEV(1))
39+
#define SDCARD_SPI_PARAM_CS (GPIO_PIN(PA, 14))
40+
#define SDCARD_SPI_PARAM_CLK (GPIO_PIN(PA, 12))
41+
#define SDCARD_SPI_PARAM_MOSI (GPIO_PIN(PA, 13))
42+
#define SDCARD_SPI_PARAM_MISO (GPIO_PIN(PA, 15))
43+
#define SDCARD_SPI_PARAM_POWER (GPIO_UNDEF)
44+
/** treated as 'don't care' if SDCARD_SPI_PARAM_POWER is GPIO_UNDEF */
45+
#define SDCARD_SPI_PARAM_POWER_AH (true)
4046
/** @} */
4147

4248
/**
43-
* @brief LED pin definitions and handlers
49+
* @brief The on-board LED is connected to pin 6 on this board
50+
*/
51+
#define ARDUINO_LED (32U)
52+
53+
/**
54+
* @name LED pin definitions and handlers
4455
* @{
4556
*/
46-
#define LED0_PIN GPIO_PIN(PA, 20)
57+
#define LED0_PIN GPIO_PIN(PB, 8)
4758

48-
#define LED_PORT PORT->Group[PA]
59+
#define LED_PORT PORT->Group[PB]
4960
#define LED0_MASK (1 << 20)
5061

5162
#define LED0_ON (LED_PORT.OUTSET.reg = LED0_MASK)
5263
#define LED0_OFF (LED_PORT.OUTCLR.reg = LED0_MASK)
5364
#define LED0_TOGGLE (LED_PORT.OUTTGL.reg = LED0_MASK)
5465
/** @} */
5566

56-
/**
57-
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
58-
*/
59-
void board_init(void);
60-
6167
#ifdef __cplusplus
6268
}
6369
#endif

boards/arduino-mkrzero/include/periph_conf.h

Lines changed: 2 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
2-
* Copyright (C) 2016 Freie Universität Berlin
3-
* 2017 Inria
2+
* Copyright (C) 2017 Inria
43
*
54
* This file is subject to the terms and conditions of the GNU Lesser
65
* General Public License v2.1. See the file LICENSE in the top level
@@ -14,218 +13,19 @@
1413
* @file
1514
* @brief Configuration of CPU peripherals for Arduino MKRZERO board
1615
*
17-
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
18-
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
19-
* @author Peter Kietzmann <peter.kietzmann@haw-hamburg.de>
2016
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
2117
*/
2218

2319
#ifndef PERIPH_CONF_H
2420
#define PERIPH_CONF_H
2521

26-
#include <stdint.h>
27-
28-
#include "cpu.h"
2922
#include "periph_cpu.h"
23+
#include "periph_conf_common.h"
3024

3125
#ifdef __cplusplus
3226
extern "C" {
3327
#endif
3428

35-
/**
36-
* @brief External oscillator and clock configuration
37-
*
38-
* For selection of the used CORECLOCK, we have implemented two choices:
39-
*
40-
* - usage of the PLL fed by the internal 8MHz oscillator divided by 8
41-
* - usage of the internal 8MHz oscillator directly, divided by N if needed
42-
*
43-
*
44-
* The PLL option allows for the usage of a wider frequency range and a more
45-
* stable clock with less jitter. This is why we use this option as default.
46-
*
47-
* The target frequency is computed from the PLL multiplier and the PLL divisor.
48-
* Use the following formula to compute your values:
49-
*
50-
* CORECLOCK = ((PLL_MUL + 1) * 1MHz) / PLL_DIV
51-
*
52-
* NOTE: The PLL circuit does not run with less than 32MHz while the maximum PLL
53-
* frequency is 96MHz. So PLL_MULL must be between 31 and 95!
54-
*
55-
*
56-
* The internal Oscillator used directly can lead to a slightly better power
57-
* efficiency to the cost of a less stable clock. Use this option when you know
58-
* what you are doing! The actual core frequency is adjusted as follows:
59-
*
60-
* CORECLOCK = 8MHz / DIV
61-
*
62-
* NOTE: A core clock frequency below 1MHz is not recommended
63-
*
64-
* @{
65-
*/
66-
#define CLOCK_USE_PLL (1)
67-
68-
#if CLOCK_USE_PLL
69-
/* edit these values to adjust the PLL output frequency */
70-
#define CLOCK_PLL_MUL (47U) /* must be >= 31 & <= 95 */
71-
#define CLOCK_PLL_DIV (1U) /* adjust to your needs */
72-
/* generate the actual used core clock frequency */
73-
#define CLOCK_CORECLOCK (((CLOCK_PLL_MUL + 1) * 1000000U) / CLOCK_PLL_DIV)
74-
#else
75-
/* edit this value to your needs */
76-
#define CLOCK_DIV (1U)
77-
/* generate the actual core clock frequency */
78-
#define CLOCK_CORECLOCK (8000000 / CLOCK_DIV)
79-
#endif
80-
/** @} */
81-
82-
/**
83-
* @name Timer peripheral configuration
84-
* @{
85-
*/
86-
#define TIMER_NUMOF (2U)
87-
#define TIMER_0_EN 1
88-
#define TIMER_1_EN 1
89-
90-
/* Timer 0 configuration */
91-
#define TIMER_0_DEV TC3->COUNT16
92-
#define TIMER_0_CHANNELS 2
93-
#define TIMER_0_MAX_VALUE (0xffff)
94-
#define TIMER_0_ISR isr_tc3
95-
96-
/* Timer 1 configuration */
97-
#define TIMER_1_DEV TC4->COUNT32
98-
#define TIMER_1_CHANNELS 2
99-
#define TIMER_1_MAX_VALUE (0xffffffff)
100-
#define TIMER_1_ISR isr_tc4
101-
102-
/** @} */
103-
104-
/**
105-
* @name UART configuration
106-
* @{
107-
*/
108-
static const uart_conf_t uart_config[] = {
109-
{
110-
.dev = &SERCOM5->USART,
111-
.rx_pin = GPIO_PIN(PB,23),
112-
.tx_pin = GPIO_PIN(PB,22),
113-
.mux = GPIO_MUX_D,
114-
.rx_pad = UART_PAD_RX_3,
115-
.tx_pad = UART_PAD_TX_2
116-
}
117-
};
118-
119-
/* interrupt function name mapping */
120-
#define UART_0_ISR isr_sercom5
121-
122-
#define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
123-
/** @} */
124-
125-
/**
126-
* @name PWM configuration
127-
* @{
128-
*/
129-
#define PWM_0_EN 1
130-
#define PWM_1_EN 1
131-
#define PWM_MAX_CHANNELS 2
132-
/* for compatibility with test application */
133-
#define PWM_0_CHANNELS PWM_MAX_CHANNELS
134-
#define PWM_1_CHANNELS PWM_MAX_CHANNELS
135-
136-
/* PWM device configuration */
137-
static const pwm_conf_t pwm_config[] = {
138-
#if PWM_0_EN
139-
{TCC0, {
140-
/* GPIO pin, MUX value, TCC channel */
141-
{ GPIO_PIN(PA, 8), GPIO_MUX_E, 0 },
142-
{ GPIO_PIN(PA, 9), GPIO_MUX_E, 1 },
143-
}},
144-
#endif
145-
#if PWM_1_EN
146-
{TCC1, {
147-
/* GPIO pin, MUX value, TCC channel */
148-
{ GPIO_PIN(PA, 6), GPIO_MUX_E, 0 },
149-
{ GPIO_PIN(PA, 7), GPIO_MUX_E, 1 },
150-
}},
151-
#endif
152-
};
153-
154-
/* number of devices that are actually defined */
155-
#define PWM_NUMOF (2U)
156-
/** @} */
157-
158-
/**
159-
* @name ADC configuration
160-
* @{
161-
*/
162-
#define ADC_CONFIG { \
163-
{ GPIO_PIN(PA, 2), 0, 0 }, \
164-
{ GPIO_PIN(PB, 2), 0, 2 }, \
165-
{ GPIO_PIN(PB, 3), 0, 3 }, \
166-
{ GPIO_PIN(PA, 4), 0, 4 }, \
167-
{ GPIO_PIN(PA, 5), 0, 5 }, \
168-
{ GPIO_PIN(PA, 6), 0, 10 }, \
169-
{ GPIO_PIN(PA, 7), 0, 10 }}
170-
171-
#define ADC_NUMOF (6)
172-
/** @} */
173-
174-
/**
175-
* @name SPI configuration
176-
* @{
177-
*/
178-
static const spi_conf_t spi_config[] = {
179-
{
180-
.dev = &SERCOM1->SPI,
181-
.miso_pin = GPIO_PIN(PA, 19),
182-
.mosi_pin = GPIO_PIN(PB, 16),
183-
.clk_pin = GPIO_PIN(PB, 17),
184-
.miso_mux = GPIO_MUX_D,
185-
.mosi_mux = GPIO_MUX_D,
186-
.clk_mux = GPIO_MUX_D,
187-
.miso_pad = SPI_PAD_MISO_3,
188-
.mosi_pad = SPI_PAD_MOSI_0_SCK_1
189-
},
190-
{
191-
.dev = &SERCOM2->SPI,
192-
.miso_pin = GPIO_PIN(PA, 15),
193-
.mosi_pin = GPIO_PIN(PA, 12),
194-
.clk_pin = GPIO_PIN(PA, 13),
195-
.miso_mux = GPIO_MUX_D,
196-
.mosi_mux = GPIO_MUX_D,
197-
.clk_mux = GPIO_MUX_D,
198-
.miso_pad = SPI_PAD_MISO_3,
199-
.mosi_pad = SPI_PAD_MOSI_2_SCK_3
200-
}
201-
};
202-
203-
#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
204-
/** @} */
205-
206-
/**
207-
* @name I2C configuration
208-
* @{
209-
*/
210-
#define I2C_NUMOF (1U)
211-
#define I2C_0_EN 1
212-
#define I2C_1_EN 0
213-
#define I2C_2_EN 0
214-
#define I2C_3_EN 0
215-
#define I2C_IRQ_PRIO 1
216-
217-
#define I2C_0_DEV SERCOM0->I2CM
218-
#define I2C_0_IRQ SERCOM0_IRQn
219-
#define I2C_0_ISR isr_sercom0
220-
/* I2C 0 GCLK */
221-
#define I2C_0_GCLK_ID SERCOM0_GCLK_ID_CORE
222-
#define I2C_0_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW
223-
/* I2C 0 pin configuration */
224-
#define I2C_0_SDA GPIO_PIN(PA, 8)
225-
#define I2C_0_SCL GPIO_PIN(PA, 9)
226-
#define I2C_0_MUX GPIO_MUX_C
227-
/** @} */
228-
22929
#ifdef __cplusplus
23030
}
23131
#endif

0 commit comments

Comments
 (0)