diff options
| author | hathach <[email protected]> | 2018-11-20 23:49:37 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-11-20 23:49:37 +0700 |
| commit | 867d3cb02d78f85d388cb3ad9fc92f06d2bc5e10 (patch) | |
| tree | 3d74b43ac9c6081aa0942cc1d9fb11513ea71299 /hw | |
| parent | 18f8217f4fd82ee822338401abd401e43d2d1592 (diff) | |
able to build and blink with metro m0
Diffstat (limited to 'hw')
| -rw-r--r-- | hw/bsp/metro_m0_express/board_metro_m0_express.c | 61 | ||||
| -rw-r--r-- | hw/bsp/metro_m0_express/board_metro_m0_express.h | 2 |
2 files changed, 61 insertions, 2 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 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 } |
