From fac9151c733878e2cde5686801044d3ed7487786 Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 28 Nov 2020 11:11:55 +0700 Subject: [PATCH] grouping samd21 --- .../samd21/boards/feather_m0_express/board.h | 50 +++++++++++++++++++ .../samd21/boards/feather_m0_express/board.mk | 16 ++++++ .../feather_m0_express/feather_m0_express.ld} | 0 .../feather_m0_express.c => samd21/family.c} | 3 +- .../board.mk => samd21/family.mk} | 20 ++------ 5 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 hw/bsp/samd21/boards/feather_m0_express/board.h create mode 100644 hw/bsp/samd21/boards/feather_m0_express/board.mk rename hw/bsp/{feather_m0_express/samd21g18a_flash.ld => samd21/boards/feather_m0_express/feather_m0_express.ld} (100%) rename hw/bsp/{feather_m0_express/feather_m0_express.c => samd21/family.c} (98%) rename hw/bsp/{feather_m0_express/board.mk => samd21/family.mk} (68%) 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 00000000..b9292b9a --- /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 00000000..a0909cb0 --- /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 similarity index 100% rename from hw/bsp/feather_m0_express/samd21g18a_flash.ld rename to 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 similarity index 98% rename from hw/bsp/feather_m0_express/feather_m0_express.c rename to hw/bsp/samd21/family.c index 4eb157c8..8259aad7 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 similarity index 68% rename from hw/bsp/feather_m0_express/board.mk rename to hw/bsp/samd21/family.mk index 61dc7c66..51fceb24 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