Skip to content

Commit

Permalink
boards/arduino-mkr1000: Updated periph config and SWD flashing (RIOT-…
Browse files Browse the repository at this point in the history
  • Loading branch information
kbumsik authored and aabadie committed May 13, 2017
1 parent b1d719e commit 6a296d2
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 53 deletions.
4 changes: 4 additions & 0 deletions boards/arduino-mkr1000/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_rtt
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
Expand Down
37 changes: 27 additions & 10 deletions boards/arduino-mkr1000/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
# define the cpu used by Arduino/Genuino MKR1000 board
export CPU = samd21
export CPU_MODEL = samd21g18a_mkr1000
export CFLAGS += -D__SAMD21G18A__

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

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

# setup the boards dependencies
include $(RIOTBOARD)/$(BOARD)/Makefile.dep
# set default serial port depending on operating system
PORT_LINUX ?= /dev/ttyUSB0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
else
# when BOSSA is used, use a different flash map
# refer https://github.com/shumatech/BOSSA for this programmer
export PROGRAMMER = bossa
export CPU_MODEL = samd21g18a_mkr1000
export CFLAGS += -D__SAMD21G18A__

# define board specific flasher options
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export OFLAGS = -O binary

#export needed for flash rule
export PORT_LINUX ?= /dev/ttyACM0
export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
endif

# setup serial terminal
include $(RIOTMAKE)/tools/serial.inc.mk

# setup the boards dependencies
include $(RIOTBOARD)/$(BOARD)/Makefile.dep
2 changes: 1 addition & 1 deletion boards/arduino-mkr1000/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ void board_init(void)
{
/* initialize the CPU */
cpu_init();
/* initialize the on-board Amber "L" LED on pin PA17 */
/* initialize the on-board Green "L" LED on pin PA20 */
gpio_init(LED0_PIN, GPIO_OUT);
}
7 changes: 7 additions & 0 deletions boards/arduino-mkr1000/dist/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source [find interface/cmsis-dap.cfg]

set CHIPNAME at91samd21g18
set ENDIAN little
set telnet_port 0

source [find target/at91samdXX.cfg]
7 changes: 7 additions & 0 deletions boards/arduino-mkr1000/include/arduino_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ static const gpio_t arduino_pinmap[] = {
ARDUINO_PIN_5,
ARDUINO_PIN_6,
ARDUINO_PIN_7,
ARDUINO_PIN_8,
ARDUINO_PIN_9,
ARDUINO_PIN_10,
ARDUINO_PIN_11,
ARDUINO_PIN_12,
ARDUINO_PIN_13,
ARDUINO_PIN_14,
ARDUINO_PIN_A0,
ARDUINO_PIN_A1,
ARDUINO_PIN_A2,
Expand Down
44 changes: 26 additions & 18 deletions boards/arduino-mkr1000/include/arduino_pinmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,34 @@ extern "C" {
#endif

/**
* @brief Mapping of MCU pins to Arduino pins
* @name Mapping of MCU pins to Arduino pins
* @{
*/
#define ARDUINO_PIN_0 GPIO_PIN(PA, 22)
#define ARDUINO_PIN_1 GPIO_PIN(PA, 23)
#define ARDUINO_PIN_2 GPIO_PIN(PA, 10)
#define ARDUINO_PIN_3 GPIO_PIN(PA, 11)
#define ARDUINO_PIN_4 GPIO_PIN(PB, 10)
#define ARDUINO_PIN_5 GPIO_PIN(PB, 11)
#define ARDUINO_PIN_6 GPIO_PIN(PA, 20) /* on-board LED */
#define ARDUINO_PIN_7 GPIO_PIN(PA, 21)

#define ARDUINO_PIN_A0 GPIO_PIN(PA, 2)
#define ARDUINO_PIN_A1 GPIO_PIN(PB, 2)
#define ARDUINO_PIN_A2 GPIO_PIN(PB, 3)
#define ARDUINO_PIN_A3 GPIO_PIN(PA, 4)
#define ARDUINO_PIN_A4 GPIO_PIN(PA, 5)
#define ARDUINO_PIN_A5 GPIO_PIN(PA, 6)
#define ARDUINO_PIN_A6 GPIO_PIN(PA, 7)
/** @ */
#define ARDUINO_PIN_0 GPIO_PIN(PA, 22) /* TC4-W0 */
#define ARDUINO_PIN_1 GPIO_PIN(PA, 23) /* TC4-W1 */
#define ARDUINO_PIN_2 GPIO_PIN(PA, 10) /* TCC0-W2 */
#define ARDUINO_PIN_3 GPIO_PIN(PA, 11) /* TCC0-W3 */
#define ARDUINO_PIN_4 GPIO_PIN(PB, 10) /* TCC0-W4 */
#define ARDUINO_PIN_5 GPIO_PIN(PB, 11) /* TCC0-W5 */
#define ARDUINO_PIN_6 GPIO_PIN(PA, 20) /* TCC0-W6, on-board LED */
#define ARDUINO_PIN_7 GPIO_PIN(PA, 21) /* TCC0-W7 */

#define ARDUINO_PIN_8 GPIO_PIN(PA, 16) /* SERCOM1-MOSI */
#define ARDUINO_PIN_9 GPIO_PIN(PA, 17) /* SERCOM1-SCK */
#define ARDUINO_PIN_10 GPIO_PIN(PA, 19) /* SERCOM1-MISO */
#define ARDUINO_PIN_11 GPIO_PIN(PA, 8) /* SERCOM0-SDA, on-board pull-up */
#define ARDUINO_PIN_12 GPIO_PIN(PA, 9) /* SERCOM0-SCL, on-board pull-up */
#define ARDUINO_PIN_13 GPIO_PIN(PB, 23) /* SERCOM5-RX from MCU */
#define ARDUINO_PIN_14 GPIO_PIN(PB, 22) /* SERCOM5-TX from MCU */

#define ARDUINO_PIN_A0 GPIO_PIN(PA, 2) /* AIN0, DAC0 */
#define ARDUINO_PIN_A1 GPIO_PIN(PB, 2) /* AIN10 */
#define ARDUINO_PIN_A2 GPIO_PIN(PB, 3) /* AIN11 */
#define ARDUINO_PIN_A3 GPIO_PIN(PA, 4) /* AIN4 */
#define ARDUINO_PIN_A4 GPIO_PIN(PA, 5) /* AIN5 */
#define ARDUINO_PIN_A5 GPIO_PIN(PA, 6) /* AIN6 */
#define ARDUINO_PIN_A6 GPIO_PIN(PA, 7) /* AIN7 */
/** @} */

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion boards/arduino-mkr1000/include/gpio_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {
static const saul_gpio_params_t saul_gpio_params[] =
{
{
.name = "LED(orange)",
.name = "LED(Green)",
.pin = LED0_PIN,
.mode = GPIO_OUT
},
Expand Down
85 changes: 62 additions & 23 deletions boards/arduino-mkr1000/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Peter Kietzmann <peter.kietzmann@haw-hamburg.de>
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
* @author Bumsik kim <kbumsik@gmail.com>
*/

#ifndef PERIPH_CONF_H
Expand Down Expand Up @@ -98,7 +99,6 @@ extern "C" {
#define TIMER_1_CHANNELS 2
#define TIMER_1_MAX_VALUE (0xffffffff)
#define TIMER_1_ISR isr_tc4

/** @} */

/**
Expand All @@ -108,8 +108,8 @@ extern "C" {
static const uart_conf_t uart_config[] = {
{
.dev = &SERCOM5->USART,
.rx_pin = GPIO_PIN(PB,23),
.tx_pin = GPIO_PIN(PB,22),
.rx_pin = GPIO_PIN(PB,23), /* ARDUINO_PIN_13, RX Pin */
.tx_pin = GPIO_PIN(PB,22), /* ARDUINO_PIN_14, TX Pin */
.mux = GPIO_MUX_D,
.rx_pad = UART_PAD_RX_3,
.tx_pad = UART_PAD_TX_2
Expand Down Expand Up @@ -159,16 +159,33 @@ static const pwm_conf_t pwm_config[] = {
* @name ADC configuration
* @{
*/
#define ADC_CONFIG { \
{ GPIO_PIN(PA, 2), 0, 0 }, \
{ GPIO_PIN(PB, 2), 0, 2 }, \
{ GPIO_PIN(PB, 3), 0, 3 }, \
{ GPIO_PIN(PA, 4), 0, 4 }, \
{ GPIO_PIN(PA, 5), 0, 5 }, \
{ GPIO_PIN(PA, 6), 0, 10 }, \
{ GPIO_PIN(PA, 7), 0, 10 }}

#define ADC_NUMOF (6)
#define ADC_0_EN 1
#define ADC_MAX_CHANNELS 14
/* ADC 0 device configuration */
#define ADC_0_DEV ADC
#define ADC_0_IRQ ADC_IRQn

/* ADC 0 Default values */
#define ADC_0_CLK_SOURCE 0 /* GCLK_GENERATOR_0 */
#define ADC_0_PRESCALER ADC_CTRLB_PRESCALER_DIV512

#define ADC_0_NEG_INPUT ADC_INPUTCTRL_MUXNEG_GND
#define ADC_0_GAIN_FACTOR_DEFAULT ADC_INPUTCTRL_GAIN_1X
#define ADC_0_REF_DEFAULT ADC_REFCTRL_REFSEL_INT1V

static const adc_conf_chan_t adc_channels[] = {
/* port, pin, muxpos */
{GPIO_PIN(PA, 2), ADC_INPUTCTRL_MUXPOS_PIN0}, /* A0 */
{GPIO_PIN(PB, 2), ADC_INPUTCTRL_MUXPOS_PIN10}, /* A1 */
{GPIO_PIN(PB, 3), ADC_INPUTCTRL_MUXPOS_PIN11}, /* A2 */
{GPIO_PIN(PA, 4), ADC_INPUTCTRL_MUXPOS_PIN4}, /* A3 */
{GPIO_PIN(PA, 5), ADC_INPUTCTRL_MUXPOS_PIN5}, /* A4 */
{GPIO_PIN(PA, 6), ADC_INPUTCTRL_MUXPOS_PIN6}, /* A5 */
{GPIO_PIN(PA, 7), ADC_INPUTCTRL_MUXPOS_PIN7}, /* A6 */
};

#define ADC_0_CHANNELS (7U)
#define ADC_NUMOF ADC_0_CHANNELS
/** @} */

/**
Expand All @@ -178,16 +195,16 @@ static const pwm_conf_t pwm_config[] = {
static const spi_conf_t spi_config[] = {
{
.dev = &SERCOM1->SPI,
.miso_pin = GPIO_PIN(PA, 19),
.mosi_pin = GPIO_PIN(PB, 16),
.clk_pin = GPIO_PIN(PB, 17),
.miso_mux = GPIO_MUX_D,
.mosi_mux = GPIO_MUX_D,
.clk_mux = GPIO_MUX_D,
.miso_pin = GPIO_PIN(PA, 19), /* ARDUINO_PIN_8, SERCOM1-MISO */
.mosi_pin = GPIO_PIN(PA, 16), /* ARDUINO_PIN_10, SERCOM1-MOSI */
.clk_pin = GPIO_PIN(PA, 17), /* ARDUINO_PIN_9, SERCOM1-SCK */
.miso_mux = GPIO_MUX_C,
.mosi_mux = GPIO_MUX_C,
.clk_mux = GPIO_MUX_C,
.miso_pad = SPI_PAD_MISO_3,
.mosi_pad = SPI_PAD_MOSI_0_SCK_1
},
{
{ /* SPI Pins connected to WINC1500 wifi module */
.dev = &SERCOM2->SPI,
.miso_pin = GPIO_PIN(PA, 15),
.mosi_pin = GPIO_PIN(PA, 12),
Expand All @@ -196,7 +213,7 @@ static const spi_conf_t spi_config[] = {
.mosi_mux = GPIO_MUX_D,
.clk_mux = GPIO_MUX_D,
.miso_pad = SPI_PAD_MISO_3,
.mosi_pad = SPI_PAD_MOSI_2_SCK_3
.mosi_pad = SPI_PAD_MOSI_0_SCK_1
}
};

Expand All @@ -221,11 +238,33 @@ static const spi_conf_t spi_config[] = {
#define I2C_0_GCLK_ID SERCOM0_GCLK_ID_CORE
#define I2C_0_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW
/* I2C 0 pin configuration */
#define I2C_0_SDA GPIO_PIN(PA, 8)
#define I2C_0_SCL GPIO_PIN(PA, 9)
#define I2C_0_SDA GPIO_PIN(PA, 8) /* SERCOM0-SDA, on-board pull-up */
#define I2C_0_SCL GPIO_PIN(PA, 9) /* SERCOM0-SCL, on-board pull-up */
#define I2C_0_MUX GPIO_MUX_C
/** @} */

/**
* @name RTC configuration
* @{
*/
#define RTC_NUMOF (1U)
#define RTC_DEV RTC->MODE2
/** @} */

/**
* @name RTT configuration
* @{
*/
#define RTT_NUMOF (1U)
#define RTT_DEV RTC->MODE0
#define RTT_IRQ RTC_IRQn
#define RTT_IRQ_PRIO 10
#define RTT_ISR isr_rtc
#define RTT_MAX_VALUE (0xffffffff)
#define RTT_FREQUENCY (32768U) /* in Hz. For changes see `rtt.c` */
#define RTT_RUNSTDBY (1) /* Keep RTT running in sleep states */
/** @} */

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 6a296d2

Please sign in to comment.