summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-11-20 23:49:37 +0700
committerhathach <[email protected]>2018-11-20 23:49:37 +0700
commit867d3cb02d78f85d388cb3ad9fc92f06d2bc5e10 (patch)
tree3d74b43ac9c6081aa0942cc1d9fb11513ea71299
parent18f8217f4fd82ee822338401abd401e43d2d1592 (diff)
able to build and blink with metro m0
-rw-r--r--examples/device/device_composite/ses/device_composite.emProject38
-rw-r--r--examples/device/device_composite/ses/ses_samd21/ATSAMD21G18A_MemoryMap.xml2
-rw-r--r--hw/bsp/metro_m0_express/board_metro_m0_express.c61
-rw-r--r--hw/bsp/metro_m0_express/board_metro_m0_express.h2
4 files changed, 79 insertions, 24 deletions
diff --git a/examples/device/device_composite/ses/device_composite.emProject b/examples/device/device_composite/ses/device_composite.emProject
index e63a9fb08..4ea41db2a 100644
--- a/examples/device/device_composite/ses/device_composite.emProject
+++ b/examples/device/device_composite/ses/device_composite.emProject
@@ -158,7 +158,7 @@
</folder>
<folder Name="hpl">
<folder Name="core">
- <file file_name="../../../../../../../adafruit/circuitpython/thach_cp/ports/atmel-samd/asf4/samd51/hpl/core/hpl_init.c" />
+ <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/core/hpl_init.c" />
</folder>
<folder Name="osc32kctrl">
<file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c" />
@@ -201,22 +201,21 @@
Name="Common"
Placement="Flash"
Target="nRF52840_xxAA"
- arm_architecture="v7EM"
- arm_core_type="Cortex-M4"
+ arm_architecture="v6M"
+ arm_core_type="Cortex-M0+"
arm_endian="Little"
- arm_fp_abi="Hard"
- arm_fpu_type="FPv4-SP-D16"
+ arm_fpu_type="None"
arm_interwork="No"
arm_linker_heap_size="1024"
arm_linker_process_stack_size="0"
arm_linker_stack_size="1024"
arm_simulator_memory_simulation_parameter="RX 00000000,00080000,FFFFFFFF;RWX 20000000,00030000,CDCDCDCD"
arm_target_debug_interface_type="ADIv5"
- arm_target_device_name="ATSAMD51J19"
+ arm_target_device_name="ATSAMD21G18A"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
c_preprocessor_definitions="__SAMD21G18A__;__SAMD21_FAMILY;__SAM_D21_SUBFAMILY;ARM_MATH_CM0PLUS;FLASH_PLACEMENT=1;USE_SIMPLE_ASSERT;CIRCUITPY_GCLK_INIT_1ST=0xffff;BOARD_METRO_M0_EXPRESS;CFG_TUSB_MCU=OPT_MCU_SAMD21"
- c_user_include_directories="../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(asf4Dir);$(asf4Dir)/include;$(asf4Dir)/config;$(asf4Dir)/hri;$(asf4Dir)/hal/include;$(asf4Dir)/hal/utils/include;$(asf4Dir)/hpl/port;$(asf4Dir)/hpl/gclk"
+ c_user_include_directories="../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(asf4Dir);$(asf4Dir)/include;$(asf4Dir)/config;$(asf4Dir)/hri;$(asf4Dir)/hal/include;$(asf4Dir)/hal/utils/include;$(asf4Dir)/hpl/port;$(asf4Dir)/hpl/gclk;$(asf4Dir)/hpl/pm"
debug_register_definition_file="ses_samd21/ATSAMD21G18A_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
@@ -228,7 +227,7 @@
project_directory=""
project_type="Executable"
target_reset_script="Reset();"
- target_script_file="$(ProjectDir)/ses_samd51/SAMD51_Target.js"
+ target_script_file="$(ProjectDir)/ses_samd21/SAMD21_Target.js"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<folder
Name="tinyusb"
@@ -249,25 +248,22 @@
<folder Name="microchip">
<folder Name="samd">
<folder Name="asf4">
- <folder Name="samd51">
+ <folder Name="samd21">
<folder Name="gcc">
- <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/gcc/system_samd51.c" />
+ <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/gcc/system_samd21.c" />
</folder>
<folder Name="hpl">
<folder Name="core">
- <file file_name="../../../../../../../adafruit/circuitpython/thach_cp/ports/atmel-samd/asf4/samd51/hpl/core/hpl_init.c" />
+ <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/core/hpl_init.c" />
</folder>
- <folder Name="osc32kctrl">
- <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c" />
+ <folder Name="gclk">
+ <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/gclk/hpl_gclk.c" />
</folder>
- <folder Name="oscctrl">
- <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/oscctrl/hpl_oscctrl.c" />
+ <folder Name="pm">
+ <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/pm/hpl_pm.c" />
</folder>
- <folder Name="mclk">
- <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/mclk/hpl_mclk.c" />
- </folder>
- <folder Name="gclk">
- <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/gclk/hpl_gclk.c" />
+ <folder Name="sysctrl">
+ <file file_name="../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/sysctrl/hpl_sysctrl.c" />
</folder>
</folder>
</folder>
@@ -283,7 +279,7 @@
filter="*.c;*.h"
path="../src"
recurse="Yes" />
- <folder Name="samd21">
+ <folder Name="ses_samd21">
<file file_name="ses_samd21/ATSAMD21G18A_MemoryMap.xml" />
<file file_name="ses_samd21/ATSAMD21G18A_Registers.xml" />
<file file_name="ses_samd21/ATSAMD21G18A_Vectors.s" />
diff --git a/examples/device/device_composite/ses/ses_samd21/ATSAMD21G18A_MemoryMap.xml b/examples/device/device_composite/ses/ses_samd21/ATSAMD21G18A_MemoryMap.xml
index f50023471..2143d3055 100644
--- a/examples/device/device_composite/ses/ses_samd21/ATSAMD21G18A_MemoryMap.xml
+++ b/examples/device/device_composite/ses/ses_samd21/ATSAMD21G18A_MemoryMap.xml
@@ -1,5 +1,5 @@
<!DOCTYPE Board_Memory_Definition_File>
<root name="ATSAMD21G18A">
- <MemorySegment name="FLASH" start="0x00000000" size="0x00040000" access="ReadOnly" />
+ <MemorySegment name="FLASH" start="0x00002000" size="0x0003E000" access="ReadOnly" />
<MemorySegment name="RAM" start="0x20000000" size="0x00008000" access="Read/Write" />
</root>
diff --git a/hw/bsp/metro_m0_express/board_metro_m0_express.c b/hw/bsp/metro_m0_express/board_metro_m0_express.c
index 0838dd2ac..6599c1343 100644
--- a/hw/bsp/metro_m0_express/board_metro_m0_express.c
+++ b/hw/bsp/metro_m0_express/board_metro_m0_express.c
@@ -36,12 +36,71 @@
*/
/**************************************************************************/
+#include "bsp/board.h"
+
+#include "sam.h"
+#include "hal/include/hal_gpio.h"
+#include "hal/include/hal_init.h"
+#include "peripheral_clk_config.h"
+
+
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
-
+#define LED_STATE_ON 1
void board_init(void)
{
+ //init_mcu();
+
+ gpio_set_pin_direction(BOARD_LED0, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(BOARD_LED0, 1-LED_STATE_ON);
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // Tick init
+ SysTick_Config(SystemCoreClock/1000);
+#endif
+
+#if 0
+ /* USB Clock init
+ * The USB module requires a GCLK_USB of 48 MHz ~ 0.25% clock
+ * for low speed and full speed operation. */
+ hri_gclk_write_PCHCTRL_reg(GCLK, USB_GCLK_ID, CONF_GCLK_USB_SRC | GCLK_PCHCTRL_CHEN);
+ hri_mclk_set_AHBMASK_USB_bit(MCLK);
+ hri_mclk_set_APBBMASK_USB_bit(MCLK);
+
+ // USB Pin Init
+ gpio_set_pin_direction(PIN_PA24, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA24, false);
+ gpio_set_pin_pull_mode(PIN_PA24, GPIO_PULL_OFF);
+ gpio_set_pin_direction(PIN_PA25, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(PIN_PA25, false);
+ gpio_set_pin_pull_mode(PIN_PA25, GPIO_PULL_OFF);
+
+ gpio_set_pin_function(PIN_PA24, PINMUX_PA24H_USB_DM);
+ gpio_set_pin_function(PIN_PA25, PINMUX_PA25H_USB_DP);
+#endif
+}
+void board_led_control(uint32_t led_id, bool state)
+{
+ gpio_set_pin_level(led_id, state ? LED_STATE_ON : (1-LED_STATE_ON));
+}
+
+
+/*------------------------------------------------------------------*/
+/* TUSB HAL MILLISECOND
+ *------------------------------------------------------------------*/
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler (void)
+{
+ system_ticks++;
+}
+
+uint32_t tusb_hal_millis(void)
+{
+ return board_tick2ms(system_ticks);
}
+#endif \ No newline at end of file
diff --git a/hw/bsp/metro_m0_express/board_metro_m0_express.h b/hw/bsp/metro_m0_express/board_metro_m0_express.h
index 4325514e8..b727d144c 100644
--- a/hw/bsp/metro_m0_express/board_metro_m0_express.h
+++ b/hw/bsp/metro_m0_express/board_metro_m0_express.h
@@ -43,7 +43,7 @@
#endif
#define BOARD_LED_NUM 1
-#define BOARD_LED0 13
+#define BOARD_LED0 17
#ifdef __cplusplus
}