Bladeren bron

board test works

hathach 6 jaren geleden
bovenliggende
commit
6baa79b330
4 gewijzigde bestanden met toevoegingen van 282 en 0 verwijderingen
  1. 50 0
      hw/bsp/samg55xplained/board.mk
  2. 114 0
      hw/bsp/samg55xplained/samg55xplained.c
  3. 116 0
      src/portable/template/dcd_template.c
  4. 2 0
      src/tusb_option.h

+ 50 - 0
hw/bsp/samg55xplained/board.mk

@@ -0,0 +1,50 @@
+CFLAGS += \
+  -D__SAMG55J19__ \
+  -mthumb \
+  -mabi=aapcs \
+  -mcpu=cortex-m4 \
+  -mfloat-abi=hard \
+  -mfpu=fpv4-sp-d16 \
+  -nostdlib -nostartfiles \
+  -DCFG_TUSB_MCU=OPT_MCU_NONE
+
+#CFLAGS += -Wno-error=undef
+
+ASF_DIR = hw/mcu/microchip/samg
+
+# All source paths should be relative to the top level.
+LD_FILE = $(ASF_DIR)/samg55/gcc/gcc/samg55j19_flash.ld
+
+SRC_C += \
+	$(ASF_DIR)/samg55/gcc/gcc/startup_samg55j19.c \
+	$(ASF_DIR)/samg55/gcc/system_samg55j19.c \
+	$(ASF_DIR)/hpl/core/hpl_init.c \
+	$(ASF_DIR)/hpl/pmc/hpl_pmc.c \
+	$(ASF_DIR)/hal/src/hal_atomic.c
+
+INC += \
+	$(TOP)/$(ASF_DIR) \
+	$(TOP)/$(ASF_DIR)/config \
+	$(TOP)/$(ASF_DIR)/samg55/include \
+	$(TOP)/$(ASF_DIR)/hal/include \
+	$(TOP)/$(ASF_DIR)/hal/utils/include \
+	$(TOP)/$(ASF_DIR)/hpl/core \
+	$(TOP)/$(ASF_DIR)/hpl/pio \
+	$(TOP)/$(ASF_DIR)/hpl/pmc \
+	$(TOP)/$(ASF_DIR)/hri \
+	$(TOP)/$(ASF_DIR)/CMSIS/Core/Include
+
+# For TinyUSB port source
+VENDOR = .
+CHIP_FAMILY = template
+
+# For freeRTOS port source
+FREERTOS_PORT = ARM_CM4F
+
+# For flash-jlink target
+JLINK_DEVICE = ATSAMD51J19
+JLINK_IF = swd
+
+# flash using edbg from https://github.com/ataradov/edbg
+flash: $(BUILD)/$(BOARD)-firmware.bin
+	edbg --verbose -t samg55 -pv -f $< 

+ 114 - 0
hw/bsp/samg55xplained/samg55xplained.c

@@ -0,0 +1,114 @@
+/* 
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019, hathach (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.
+ *
+ */
+
+#include "sam.h"
+#include "peripheral_clk_config.h"
+#include "hal/include/hal_init.h"
+#include "hpl/pmc/hpl_pmc.h"
+#include "hal/include/hal_gpio.h"
+
+#include "bsp/board.h"
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+#define LED_PIN               GPIO(GPIO_PORTA, 6)
+
+#define BUTTON_PIN            GPIO(GPIO_PORTA, 2)
+#define BUTTON_STATE_ACTIVE   0
+
+//------------- IMPLEMENTATION -------------//
+void board_init(void)
+{
+	init_mcu();
+
+	_pmc_enable_periph_clock(ID_PIOA);
+
+	/* Disable Watchdog */
+	hri_wdt_set_MR_WDDIS_bit(WDT);
+
+	// LED
+	gpio_set_pin_level(LED_PIN, false);
+	gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT);
+	gpio_set_pin_function(LED_PIN, GPIO_PIN_FUNCTION_OFF);
+
+	// Button
+	gpio_set_pin_direction(BUTTON_PIN, GPIO_DIRECTION_IN);
+	gpio_set_pin_pull_mode(BUTTON_PIN, GPIO_PULL_UP);
+	gpio_set_pin_function(BUTTON_PIN, GPIO_PIN_FUNCTION_OFF);
+
+#if CFG_TUSB_OS  == OPT_OS_NONE
+  // 1ms tick timer (samd SystemCoreClock may not correct)
+  SysTick_Config(CONF_CPU_FREQUENCY / 1000);
+#endif
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state)
+{
+  gpio_set_pin_level(LED_PIN, state);
+}
+
+uint32_t board_button_read(void)
+{
+  return BUTTON_STATE_ACTIVE == gpio_get_pin_level(BUTTON_PIN);
+}
+
+int board_uart_read(uint8_t* buf, int len)
+{
+  (void) buf; (void) len;
+  return 0;
+}
+
+int board_uart_write(void const * buf, int len)
+{
+  (void) buf; (void) len;
+  return 0;
+}
+
+#if CFG_TUSB_OS  == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler (void)
+{
+  system_ticks++;
+}
+
+uint32_t board_millis(void)
+{
+  return system_ticks;
+}
+#endif
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void)
+{
+
+}

+ 116 - 0
src/portable/template/dcd_template.c

@@ -0,0 +1,116 @@
+/* 
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018, hathach (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.
+ */
+
+#include "tusb_option.h"
+
+#if CFG_TUSB_MCU == OPT_MCU_NONE
+
+#include "device/dcd.h"
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM DECLARATION
+//--------------------------------------------------------------------+
+
+
+/*------------------------------------------------------------------*/
+/* Device API
+ *------------------------------------------------------------------*/
+
+// Initialize controller to device mode
+void dcd_init (uint8_t rhport)
+{
+  (void) rhport;
+}
+
+// Enable device interrupt
+void dcd_int_enable (uint8_t rhport)
+{
+  (void) rhport;
+}
+
+// Disable device interrupt
+void dcd_int_disable (uint8_t rhport)
+{
+  (void) rhport;
+}
+
+// Receive Set Address request, mcu port must also include status IN response
+void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
+{
+  (void) rhport;
+  (void) dev_addr;
+}
+
+// Receive Set Configure request
+void dcd_set_config (uint8_t rhport, uint8_t config_num)
+{
+  (void) rhport;
+  (void) config_num;
+}
+
+// Wake up host
+void dcd_remote_wakeup (uint8_t rhport)
+{
+  (void) rhport;
+}
+
+//--------------------------------------------------------------------+
+// Endpoint API
+//--------------------------------------------------------------------+
+
+// Configure endpoint's registers according to descriptor
+bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
+{
+  (void) rhport;
+  (void) ep_desc;
+  return false;
+}
+
+// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
+bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
+{
+  (void) rhport;
+  (void) ep_addr;
+  (void) buffer;
+  (void) total_bytes;
+  return false;
+}
+
+// Stall endpoint
+void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
+{
+  (void) rhport;
+  (void) ep_addr;
+}
+
+// clear stall, data toggle is also reset to DATA0
+void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
+{
+  (void) rhport;
+  (void) ep_addr;
+}
+
+#endif

+ 2 - 0
src/tusb_option.h

@@ -36,6 +36,8 @@
  * \ref CFG_TUSB_MCU must be defined to one of these
  *  @{ */
 
+#define OPT_MCU_NONE            0
+
 // LPC
 #define OPT_MCU_LPC11UXX        1 ///< NXP LPC11Uxx
 #define OPT_MCU_LPC13XX         2 ///< NXP LPC13xx