Skip to content

Commit 3e9b1c4

Browse files
kbumsikaabadie
authored andcommitted
boards/arduino-mkr1000: Updated periph config and SWD flashing (#3)
1 parent fc6c6ae commit 3e9b1c4

File tree

8 files changed

+135
-53
lines changed

8 files changed

+135
-53
lines changed

boards/arduino-mkr1000/Makefile.features

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Put defined MCU peripherals here (in alphabetical order)
2+
FEATURES_PROVIDED += periph_adc
23
FEATURES_PROVIDED += periph_cpuid
34
FEATURES_PROVIDED += periph_gpio
45
FEATURES_PROVIDED += periph_i2c
6+
FEATURES_PROVIDED += periph_pwm
7+
FEATURES_PROVIDED += periph_rtc
8+
FEATURES_PROVIDED += periph_rtt
59
FEATURES_PROVIDED += periph_spi
610
FEATURES_PROVIDED += periph_timer
711
FEATURES_PROVIDED += periph_uart
Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
# define the cpu used by Arduino/Genuino MKR1000 board
22
export CPU = samd21
3-
export CPU_MODEL = samd21g18a_mkr1000
4-
export CFLAGS += -D__SAMD21G18A__
53

6-
# set default port depending on operating system
7-
PORT_LINUX ?= /dev/ttyACM0
8-
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
4+
ifeq ($(PROGRAMMER),jlink)
5+
# in case J-Link is attached to SWD pins, use a plain CPU memory model
6+
export CPU_MODEL = samd21g18a
97

10-
# define board specific flasher options
11-
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
12-
export OFLAGS = -O binary
8+
# setup JLink for flashing
9+
export JLINK_DEVICE := atsamw25
10+
include $(RIOTMAKE)/tools/jlink.inc.mk
1311

14-
# setup the boards dependencies
15-
include $(RIOTBOARD)/$(BOARD)/Makefile.dep
12+
# set default serial port depending on operating system
13+
PORT_LINUX ?= /dev/ttyUSB0
14+
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
15+
else
16+
# when BOSSA is used, use a different flash map
17+
# refer https://github.com/shumatech/BOSSA for this programmer
18+
export PROGRAMMER = bossa
19+
export CPU_MODEL = samd21g18a_mkr1000
20+
export CFLAGS += -D__SAMD21G18A__
21+
22+
# define board specific flasher options
23+
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
24+
export OFLAGS = -O binary
25+
26+
#export needed for flash rule
27+
export PORT_LINUX ?= /dev/ttyACM0
28+
export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
29+
endif
1630

1731
# setup serial terminal
1832
include $(RIOTMAKE)/tools/serial.inc.mk
33+
34+
# setup the boards dependencies
35+
include $(RIOTBOARD)/$(BOARD)/Makefile.dep

boards/arduino-mkr1000/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ void board_init(void)
2828
{
2929
/* initialize the CPU */
3030
cpu_init();
31-
/* initialize the on-board Amber "L" LED on pin PA17 */
31+
/* initialize the on-board Green "L" LED on pin PA20 */
3232
gpio_init(LED0_PIN, GPIO_OUT);
3333
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source [find interface/cmsis-dap.cfg]
2+
3+
set CHIPNAME at91samd21g18
4+
set ENDIAN little
5+
set telnet_port 0
6+
7+
source [find target/at91samdXX.cfg]

boards/arduino-mkr1000/include/arduino_board.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ static const gpio_t arduino_pinmap[] = {
4444
ARDUINO_PIN_5,
4545
ARDUINO_PIN_6,
4646
ARDUINO_PIN_7,
47+
ARDUINO_PIN_8,
48+
ARDUINO_PIN_9,
49+
ARDUINO_PIN_10,
50+
ARDUINO_PIN_11,
51+
ARDUINO_PIN_12,
52+
ARDUINO_PIN_13,
53+
ARDUINO_PIN_14,
4754
ARDUINO_PIN_A0,
4855
ARDUINO_PIN_A1,
4956
ARDUINO_PIN_A2,

boards/arduino-mkr1000/include/arduino_pinmap.h

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,34 @@ extern "C" {
2929
#endif
3030

3131
/**
32-
* @brief Mapping of MCU pins to Arduino pins
32+
* @name Mapping of MCU pins to Arduino pins
3333
* @{
3434
*/
35-
#define ARDUINO_PIN_0 GPIO_PIN(PA, 22)
36-
#define ARDUINO_PIN_1 GPIO_PIN(PA, 23)
37-
#define ARDUINO_PIN_2 GPIO_PIN(PA, 10)
38-
#define ARDUINO_PIN_3 GPIO_PIN(PA, 11)
39-
#define ARDUINO_PIN_4 GPIO_PIN(PB, 10)
40-
#define ARDUINO_PIN_5 GPIO_PIN(PB, 11)
41-
#define ARDUINO_PIN_6 GPIO_PIN(PA, 20) /* on-board LED */
42-
#define ARDUINO_PIN_7 GPIO_PIN(PA, 21)
43-
44-
#define ARDUINO_PIN_A0 GPIO_PIN(PA, 2)
45-
#define ARDUINO_PIN_A1 GPIO_PIN(PB, 2)
46-
#define ARDUINO_PIN_A2 GPIO_PIN(PB, 3)
47-
#define ARDUINO_PIN_A3 GPIO_PIN(PA, 4)
48-
#define ARDUINO_PIN_A4 GPIO_PIN(PA, 5)
49-
#define ARDUINO_PIN_A5 GPIO_PIN(PA, 6)
50-
#define ARDUINO_PIN_A6 GPIO_PIN(PA, 7)
51-
/** @ */
35+
#define ARDUINO_PIN_0 GPIO_PIN(PA, 22) /* TC4-W0 */
36+
#define ARDUINO_PIN_1 GPIO_PIN(PA, 23) /* TC4-W1 */
37+
#define ARDUINO_PIN_2 GPIO_PIN(PA, 10) /* TCC0-W2 */
38+
#define ARDUINO_PIN_3 GPIO_PIN(PA, 11) /* TCC0-W3 */
39+
#define ARDUINO_PIN_4 GPIO_PIN(PB, 10) /* TCC0-W4 */
40+
#define ARDUINO_PIN_5 GPIO_PIN(PB, 11) /* TCC0-W5 */
41+
#define ARDUINO_PIN_6 GPIO_PIN(PA, 20) /* TCC0-W6, on-board LED */
42+
#define ARDUINO_PIN_7 GPIO_PIN(PA, 21) /* TCC0-W7 */
43+
44+
#define ARDUINO_PIN_8 GPIO_PIN(PA, 16) /* SERCOM1-MOSI */
45+
#define ARDUINO_PIN_9 GPIO_PIN(PA, 17) /* SERCOM1-SCK */
46+
#define ARDUINO_PIN_10 GPIO_PIN(PA, 19) /* SERCOM1-MISO */
47+
#define ARDUINO_PIN_11 GPIO_PIN(PA, 8) /* SERCOM0-SDA, on-board pull-up */
48+
#define ARDUINO_PIN_12 GPIO_PIN(PA, 9) /* SERCOM0-SCL, on-board pull-up */
49+
#define ARDUINO_PIN_13 GPIO_PIN(PB, 23) /* SERCOM5-RX from MCU */
50+
#define ARDUINO_PIN_14 GPIO_PIN(PB, 22) /* SERCOM5-TX from MCU */
51+
52+
#define ARDUINO_PIN_A0 GPIO_PIN(PA, 2) /* AIN0, DAC0 */
53+
#define ARDUINO_PIN_A1 GPIO_PIN(PB, 2) /* AIN10 */
54+
#define ARDUINO_PIN_A2 GPIO_PIN(PB, 3) /* AIN11 */
55+
#define ARDUINO_PIN_A3 GPIO_PIN(PA, 4) /* AIN4 */
56+
#define ARDUINO_PIN_A4 GPIO_PIN(PA, 5) /* AIN5 */
57+
#define ARDUINO_PIN_A5 GPIO_PIN(PA, 6) /* AIN6 */
58+
#define ARDUINO_PIN_A6 GPIO_PIN(PA, 7) /* AIN7 */
59+
/** @} */
5260

5361
#ifdef __cplusplus
5462
}

boards/arduino-mkr1000/include/gpio_params.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C" {
3434
static const saul_gpio_params_t saul_gpio_params[] =
3535
{
3636
{
37-
.name = "LED(orange)",
37+
.name = "LED(Green)",
3838
.pin = LED0_PIN,
3939
.mode = GPIO_OUT
4040
},

boards/arduino-mkr1000/include/periph_conf.h

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
1919
* @author Peter Kietzmann <peter.kietzmann@haw-hamburg.de>
2020
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
21+
* @author Bumsik kim <kbumsik@gmail.com>
2122
*/
2223

2324
#ifndef PERIPH_CONF_H
@@ -98,7 +99,6 @@ extern "C" {
9899
#define TIMER_1_CHANNELS 2
99100
#define TIMER_1_MAX_VALUE (0xffffffff)
100101
#define TIMER_1_ISR isr_tc4
101-
102102
/** @} */
103103

104104
/**
@@ -108,8 +108,8 @@ extern "C" {
108108
static const uart_conf_t uart_config[] = {
109109
{
110110
.dev = &SERCOM5->USART,
111-
.rx_pin = GPIO_PIN(PB,23),
112-
.tx_pin = GPIO_PIN(PB,22),
111+
.rx_pin = GPIO_PIN(PB,23), /* ARDUINO_PIN_13, RX Pin */
112+
.tx_pin = GPIO_PIN(PB,22), /* ARDUINO_PIN_14, TX Pin */
113113
.mux = GPIO_MUX_D,
114114
.rx_pad = UART_PAD_RX_3,
115115
.tx_pad = UART_PAD_TX_2
@@ -159,16 +159,33 @@ static const pwm_conf_t pwm_config[] = {
159159
* @name ADC configuration
160160
* @{
161161
*/
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)
162+
#define ADC_0_EN 1
163+
#define ADC_MAX_CHANNELS 14
164+
/* ADC 0 device configuration */
165+
#define ADC_0_DEV ADC
166+
#define ADC_0_IRQ ADC_IRQn
167+
168+
/* ADC 0 Default values */
169+
#define ADC_0_CLK_SOURCE 0 /* GCLK_GENERATOR_0 */
170+
#define ADC_0_PRESCALER ADC_CTRLB_PRESCALER_DIV512
171+
172+
#define ADC_0_NEG_INPUT ADC_INPUTCTRL_MUXNEG_GND
173+
#define ADC_0_GAIN_FACTOR_DEFAULT ADC_INPUTCTRL_GAIN_1X
174+
#define ADC_0_REF_DEFAULT ADC_REFCTRL_REFSEL_INT1V
175+
176+
static const adc_conf_chan_t adc_channels[] = {
177+
/* port, pin, muxpos */
178+
{GPIO_PIN(PA, 2), ADC_INPUTCTRL_MUXPOS_PIN0}, /* A0 */
179+
{GPIO_PIN(PB, 2), ADC_INPUTCTRL_MUXPOS_PIN10}, /* A1 */
180+
{GPIO_PIN(PB, 3), ADC_INPUTCTRL_MUXPOS_PIN11}, /* A2 */
181+
{GPIO_PIN(PA, 4), ADC_INPUTCTRL_MUXPOS_PIN4}, /* A3 */
182+
{GPIO_PIN(PA, 5), ADC_INPUTCTRL_MUXPOS_PIN5}, /* A4 */
183+
{GPIO_PIN(PA, 6), ADC_INPUTCTRL_MUXPOS_PIN6}, /* A5 */
184+
{GPIO_PIN(PA, 7), ADC_INPUTCTRL_MUXPOS_PIN7}, /* A6 */
185+
};
186+
187+
#define ADC_0_CHANNELS (7U)
188+
#define ADC_NUMOF ADC_0_CHANNELS
172189
/** @} */
173190

174191
/**
@@ -178,16 +195,16 @@ static const pwm_conf_t pwm_config[] = {
178195
static const spi_conf_t spi_config[] = {
179196
{
180197
.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,
198+
.miso_pin = GPIO_PIN(PA, 19), /* ARDUINO_PIN_8, SERCOM1-MISO */
199+
.mosi_pin = GPIO_PIN(PA, 16), /* ARDUINO_PIN_10, SERCOM1-MOSI */
200+
.clk_pin = GPIO_PIN(PA, 17), /* ARDUINO_PIN_9, SERCOM1-SCK */
201+
.miso_mux = GPIO_MUX_C,
202+
.mosi_mux = GPIO_MUX_C,
203+
.clk_mux = GPIO_MUX_C,
187204
.miso_pad = SPI_PAD_MISO_3,
188205
.mosi_pad = SPI_PAD_MOSI_0_SCK_1
189206
},
190-
{
207+
{ /* SPI Pins connected to WINC1500 wifi module */
191208
.dev = &SERCOM2->SPI,
192209
.miso_pin = GPIO_PIN(PA, 15),
193210
.mosi_pin = GPIO_PIN(PA, 12),
@@ -196,7 +213,7 @@ static const spi_conf_t spi_config[] = {
196213
.mosi_mux = GPIO_MUX_D,
197214
.clk_mux = GPIO_MUX_D,
198215
.miso_pad = SPI_PAD_MISO_3,
199-
.mosi_pad = SPI_PAD_MOSI_2_SCK_3
216+
.mosi_pad = SPI_PAD_MOSI_0_SCK_1
200217
}
201218
};
202219

@@ -221,11 +238,33 @@ static const spi_conf_t spi_config[] = {
221238
#define I2C_0_GCLK_ID SERCOM0_GCLK_ID_CORE
222239
#define I2C_0_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW
223240
/* I2C 0 pin configuration */
224-
#define I2C_0_SDA GPIO_PIN(PA, 8)
225-
#define I2C_0_SCL GPIO_PIN(PA, 9)
241+
#define I2C_0_SDA GPIO_PIN(PA, 8) /* SERCOM0-SDA, on-board pull-up */
242+
#define I2C_0_SCL GPIO_PIN(PA, 9) /* SERCOM0-SCL, on-board pull-up */
226243
#define I2C_0_MUX GPIO_MUX_C
227244
/** @} */
228245

246+
/**
247+
* @name RTC configuration
248+
* @{
249+
*/
250+
#define RTC_NUMOF (1U)
251+
#define RTC_DEV RTC->MODE2
252+
/** @} */
253+
254+
/**
255+
* @name RTT configuration
256+
* @{
257+
*/
258+
#define RTT_NUMOF (1U)
259+
#define RTT_DEV RTC->MODE0
260+
#define RTT_IRQ RTC_IRQn
261+
#define RTT_IRQ_PRIO 10
262+
#define RTT_ISR isr_rtc
263+
#define RTT_MAX_VALUE (0xffffffff)
264+
#define RTT_FREQUENCY (32768U) /* in Hz. For changes see `rtt.c` */
265+
#define RTT_RUNSTDBY (1) /* Keep RTT running in sleep states */
266+
/** @} */
267+
229268
#ifdef __cplusplus
230269
}
231270
#endif

0 commit comments

Comments
 (0)