summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-11-21 00:19:38 +0700
committerhathach <[email protected]>2018-11-21 00:19:38 +0700
commiteadcba75a2e3f9787923d4330fb9e89c08d4651f (patch)
tree292bd232453473bf828aa917e6458116a8131268
parenta46b42a54e2926a33231c657777882f87e0c0daa (diff)
has issue with metro m0 clock init
-rw-r--r--hw/bsp/metro_m0_express/board_metro_m0_express.c23
-rw-r--r--hw/bsp/metro_m4_express/board_metro_m4_express.c2
2 files changed, 22 insertions, 3 deletions
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 6599c1343..3b0edb400 100644
--- a/hw/bsp/metro_m0_express/board_metro_m0_express.c
+++ b/hw/bsp/metro_m0_express/board_metro_m0_express.c
@@ -41,6 +41,9 @@
#include "sam.h"
#include "hal/include/hal_gpio.h"
#include "hal/include/hal_init.h"
+#include <hpl_gclk_base.h>
+#include <hpl_pm_config.h>
+#include <hpl_pm_base.h>
#include "peripheral_clk_config.h"
@@ -49,9 +52,25 @@
//--------------------------------------------------------------------+
#define LED_STATE_ON 1
+/* Referenced GCLKs, should be initialized firstly */
+#define _GCLK_INIT_1ST (1 << 0 | 1 << 1)
+
+/* Not referenced GCLKs, initialized last */
+#define _GCLK_INIT_LAST (~_GCLK_INIT_1ST)
+
void board_init(void)
{
- //init_mcu();
+ // Clock init ( follow hpl_init.c )
+
+ // hri_nvmctrl_set_CTRLA_RWS_bf(NVMCTRL, CONF_NVM_WAIT_STATE);
+
+ _pm_init();
+ _sysctrl_init_sources();
+#if _GCLK_INIT_1ST
+ _gclk_init_generators_by_fref(_GCLK_INIT_1ST);
+#endif
+ _sysctrl_init_referenced_generators();
+ _gclk_init_generators_by_fref(_GCLK_INIT_LAST);
gpio_set_pin_direction(BOARD_LED0, GPIO_DIRECTION_OUT);
gpio_set_pin_level(BOARD_LED0, 1-LED_STATE_ON);
@@ -103,4 +122,4 @@ uint32_t tusb_hal_millis(void)
{
return board_tick2ms(system_ticks);
}
-#endif \ No newline at end of file
+#endif
diff --git a/hw/bsp/metro_m4_express/board_metro_m4_express.c b/hw/bsp/metro_m4_express/board_metro_m4_express.c
index 0c251e808..ef8516741 100644
--- a/hw/bsp/metro_m4_express/board_metro_m4_express.c
+++ b/hw/bsp/metro_m4_express/board_metro_m4_express.c
@@ -60,7 +60,7 @@
void board_init(void)
{
// Clock init ( follow hpl_init.c )
- //hri_nvmctrl_set_CTRLA_RWS_bf(NVMCTRL, CONF_NVM_WAIT_STATE);
+ // hri_nvmctrl_set_CTRLA_RWS_bf(NVMCTRL, CONF_NVM_WAIT_STATE);
_osc32kctrl_init_sources();
_oscctrl_init_sources();