summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2020-11-28 11:11:55 +0700
committerhathach <[email protected]>2020-11-28 11:11:55 +0700
commitfac9151c733878e2cde5686801044d3ed7487786 (patch)
tree62707f71c85465d84b05f6e3948a94f19ae7a8b5
parent630692d81b8cfdb459a28dad632cbe13ad031492 (diff)
grouping samd21
-rw-r--r--hw/bsp/samd21/boards/feather_m0_express/board.h50
-rw-r--r--hw/bsp/samd21/boards/feather_m0_express/board.mk16
-rw-r--r--hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld (renamed from hw/bsp/feather_m0_express/samd21g18a_flash.ld)0
-rw-r--r--hw/bsp/samd21/family.c (renamed from hw/bsp/feather_m0_express/feather_m0_express.c)3
-rw-r--r--hw/bsp/samd21/family.mk (renamed from hw/bsp/feather_m0_express/board.mk)20
5 files changed, 72 insertions, 17 deletions
diff --git a/hw/bsp/samd21/boards/feather_m0_express/board.h b/hw/bsp/samd21/boards/feather_m0_express/board.h
new file mode 100644
index 000000000..b9292b9af
--- /dev/null
+++ b/hw/bsp/samd21/boards/feather_m0_express/board.h
@@ -0,0 +1,50 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// LED
+#define LED_PIN 17
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PIN 15
+#define BUTTON_STATE_ACTIVE 0
+
+// UART
+#define UART_RX_PIN 4
+#define UART_TX_PIN 5
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/samd21/boards/feather_m0_express/board.mk b/hw/bsp/samd21/boards/feather_m0_express/board.mk
new file mode 100644
index 000000000..a0909cb09
--- /dev/null
+++ b/hw/bsp/samd21/boards/feather_m0_express/board.mk
@@ -0,0 +1,16 @@
+CFLAGS += -D__SAMD21G18A__
+
+# All source paths should be relative to the top level.
+LD_FILE = $(BOARD_PATH)/feather_m0_express.ld
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD21G18
+
+# flash using bossac at least version 1.8
+# can be found in arduino15/packages/arduino/tools/bossac/
+# Add it to your PATH or change BOSSAC variable to match your installation
+BOSSAC = bossac
+
+flash: $(BUILD)/$(BOARD)-firmware.bin
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
+ $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x2000 -e -w $^ -R
diff --git a/hw/bsp/feather_m0_express/samd21g18a_flash.ld b/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld
index f0c93340c..f0c93340c 100644
--- a/hw/bsp/feather_m0_express/samd21g18a_flash.ld
+++ b/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld
diff --git a/hw/bsp/feather_m0_express/feather_m0_express.c b/hw/bsp/samd21/family.c
index 4eb157c8f..8259aad70 100644
--- a/hw/bsp/feather_m0_express/feather_m0_express.c
+++ b/hw/bsp/samd21/family.c
@@ -26,6 +26,7 @@
#include "sam.h"
#include "bsp/board.h"
+#include "board.h"
#include "hal/include/hal_gpio.h"
#include "hal/include/hal_init.h"
@@ -46,8 +47,6 @@ void USB_Handler(void)
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
-#define LED_PIN 17
-#define BUTTON_PIN 15 // pin D5
/* Referenced GCLKs, should be initialized firstly */
#define _GCLK_INIT_1ST (1 << 0 | 1 << 1)
diff --git a/hw/bsp/feather_m0_express/board.mk b/hw/bsp/samd21/family.mk
index 61dc7c665..51fceb240 100644
--- a/hw/bsp/feather_m0_express/board.mk
+++ b/hw/bsp/samd21/family.mk
@@ -1,15 +1,16 @@
+include $(TOP)/$(BOARD_PATH)/board.mk
+
CFLAGS += \
-flto \
-mthumb \
- -mabi=aapcs-linux \
+ -mabi=aapcs \
-mcpu=cortex-m0plus \
-nostdlib -nostartfiles \
- -D__SAMD21G18A__ \
-DCONF_DFLL_OVERWRITE_CALIBRATION=0 \
-DCFG_TUSB_MCU=OPT_MCU_SAMD21
# All source paths should be relative to the top level.
-LD_FILE = hw/bsp/$(BOARD)/samd21g18a_flash.ld
+#LD_FILE = hw/bsp/$(BOARD)/samd21g18a_flash.ld
SRC_C += \
hw/mcu/microchip/asf4/samd21/gcc/gcc/startup_samd21.c \
@@ -20,6 +21,7 @@ SRC_C += \
hw/mcu/microchip/asf4/samd21/hal/src/hal_atomic.c
INC += \
+ $(TOP)/$(BOARD_PATH) \
$(TOP)/hw/mcu/microchip/asf4/samd21/ \
$(TOP)/hw/mcu/microchip/asf4/samd21/config \
$(TOP)/hw/mcu/microchip/asf4/samd21/include \
@@ -36,15 +38,3 @@ CHIP_FAMILY = samd
# For freeRTOS port source
FREERTOS_PORT = ARM_CM0
-
-# For flash-jlink target
-JLINK_DEVICE = ATSAMD21G18
-
-# flash using bossac at least version 1.8
-# can be found in arduino15/packages/arduino/tools/bossac/
-# Add it to your PATH or change BOSSAC variable to match your installation
-BOSSAC = bossac
-
-flash: $(BUILD)/$(BOARD)-firmware.bin
- @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
- $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x2000 -e -w $^ -R